Apt-get simulate command

65 views
Skip to first unread message

Rémi Morel

unread,
Aug 22, 2016, 8:35:03 AM8/22/16
to Ansible Project
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".

Jean-Yves LENHOF

unread,
Aug 22, 2016, 9:25:34 AM8/22/16
to ansible...@googlegroups.com
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

Kai Stian Olstad

unread,
Aug 22, 2016, 9:34:49 AM8/22/16
to ansible...@googlegroups.com
On 22. aug. 2016 09:19, Rémi Morel wrote:
> 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

The result of the command is registered in the variable updateD


> when: (ansible_os_family == "Debian") and (installD is defined) and ( {{
> item.rc }} == 0)

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


> 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".

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

- debug: var=updateD


--
Kai Stian Olstad

Rémi Morel

unread,
Aug 22, 2016, 9:49:59 AM8/22/16
to Ansible Project
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

Rémi Morel

unread,
Aug 24, 2016, 1:59:10 AM8/24/16
to Ansible Project, ansible-pr...@olstad.com
Thanks for the advice !
Reply all
Reply to author
Forward
0 new messages