# Apt-get simulate command

**URL:** <https://forum.ansible.com/t/apt-get-simulate-command/22338>\
**Category:** Ansible Project\
**Created:** [August 22, 2016, 7:19am UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338 "2016-08-22T07:19:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remi\_Morel](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@Remi\_Morel](https://forum.ansible.com/u/Remi_Morel)\
**Post date:** [August 22, 2016, 7:19am UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338/1 "2016-08-22T07:19:08Z")

</div>

Hello,

I have spend a lot of time to find a solution at this issue.  
I have a task :

`

- name: check updated package (Debian)  
command: apt-get -s install {{ item.item }}  
register: updateD  
when: (ansible\_os\_family == “Debian”) and (installD is defined) and ( {{ item.rc }} == 0)  
with\_items: “{{ installD.results }}”  
failed\_when: updateD \> 1  
changed\_when: no  
`

and Ansible reaction is :

[WARNING]: Consider using apt module rather than running apt-get

But I don’t find any option in documentation to obtain the result of “-s”.

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [August 22, 2016, 1:25pm UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338/2 "2016-08-22T13:25:17Z")

</div>

Hi,

Could you explain what you want to do ?  
To not do things in ansible but simulate, there’s --check command line option

Regards,

JYL

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 22, 2016, 1:34pm UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338/3 "2016-08-22T13:34:17Z")

</div>

> Hello,
> 
> I have spend a lot of time to find a solution at this issue.  
> I have a task :
> 
> - name: check updated package (Debian)  
> &nbsp;&nbsp;command: apt-get -s install {{ item.item }}  
> &nbsp;&nbsp;register: updateD

The result of the command is registered in the variable updateD

> &nbsp;&nbsp;when: (ansible\_os\_family == "Debian") and (installD is defined) and ( {{  
> item.rc }} == 0)

You should not use {{ }} in when, they are implied.

> &nbsp;&nbsp;with\_items: "{{ installD.results }}"  
> &nbsp;&nbsp;failed\_when: updateD \> 1  
> &nbsp;&nbsp;changed\_when: no
> 
> and Ansible reaction is :
> 
> [WARNING]: Consider using apt module rather than running apt-get
> 
> But I don't find any option in documentation to obtain the result of "-s".

Since they are in the variable updateD you can print out all of them like this.

- debug: var=updateD

---

<div class="post-metadata">

**Author:** ![Remi\_Morel](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@Remi\_Morel](https://forum.ansible.com/u/Remi_Morel)\
**Post date:** [August 22, 2016, 1:35pm UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338/4 "2016-08-22T13:35:08Z")

</div>

I want to check if a package need to be updated and write a log file. That why i use apt-get -s install, and I put the result with a register to use it later.

Thanks for watching my problem.

RM

---

<div class="post-metadata">

**Author:** ![Remi\_Morel](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@Remi\_Morel](https://forum.ansible.com/u/Remi_Morel)\
**Post date:** [August 24, 2016, 5:59am UTC](https://forum.ansible.com/t/apt-get-simulate-command/22338/5 "2016-08-24T05:59:10Z")

</div>

Thanks for the advice !
