Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Bobby Hood
Thanks, I thought that might be it. Seems pointless to suppress all the 
output. I used the "command" module instead with all the same parameters 
except --quiet and --xmlout and it's working fine. And since I can't use 
the "changed" parameter with command to see if any packages were updated 
(it always seems to return true), I'm instead checking its stdout for the 
string "Nothing to do".

On Thursday, June 13, 2019 at 5:17:19 PM UTC-6, Sebastian Meyer wrote:
>
> Hi, 
>
> On 13.06.19 23:50, Bobby Hood wrote: 
> >"cmd": [ 
> >"/usr/bin/zypper",   
> >"--quiet",   
>
> the ansible zypper module calls zypper with --quiet, as you can check on 
> the commandline that leads to zypper not writing to stdout, if there's 
> nothing to do: 
>
> # zypper update 
> Loading repository data... 
> Reading installed packages... 
>
> Nothing to do. 
> # 
> # zypper --quiet update 
> # 
>
> As this is hardcoded in the module, there's no easy way around this. It 
> should give you output once there are packages to update: 
>
> # zypper --quiet --non-interactive up 
>
> The following 6 NEW packages are going to be installed: 
>   dbus-1 kbd kmod pinentry pkg-config udev 
>
> The following 56 packages are going to be upgraded: 
>   aaa_base acl bash blog ca-certificates-mozilla cpio file [...] 
>
> The following product is going to be reinstalled: 
>   "openSUSE Leap 42.3" 
>
> 56 packages to upgrade, 6 new. 
> Overall download size: 27.8 MiB. Already cached: 0 B. After the operation, 
> additional 12.4 MiB will be used. 
> Continue? [y/n/...? shows all options] (y): y 
>
> Regards 
> -- 
> Sebastian Meyer 
> Linux Consultant & Trainer 
> Mail: me...@b1-systems.de  
>
> B1 Systems GmbH 
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de 
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 
>

-- 
This e-mail message (including any attachments) is for the sole use of the 
intended recipient(s) and may contain confidential, privileged, and/or 
proprietary information. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this message (including any attachments) is strictly prohibited.


If you have received this message in error, please contact the sender by 
reply e-mail message and destroy all copies of the original message 
(including attachments).

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dd383574-662f-4c52-ba85-6ed346057842%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Bobby Hood
Thanks, I thought that might be it. I used the command module instead with 
all the same parameters except --quiet and --xmlout and it's working fine. 
Seems pointless that it suppresses all the output.

On Thursday, June 13, 2019 at 5:17:19 PM UTC-6, Sebastian Meyer wrote:
>
> Hi, 
>
> On 13.06.19 23:50, Bobby Hood wrote: 
> >"cmd": [ 
> >"/usr/bin/zypper",   
> >"--quiet",   
>
> the ansible zypper module calls zypper with --quiet, as you can check on 
> the commandline that leads to zypper not writing to stdout, if there's 
> nothing to do: 
>
> # zypper update 
> Loading repository data... 
> Reading installed packages... 
>
> Nothing to do. 
> # 
> # zypper --quiet update 
> # 
>
> As this is hardcoded in the module, there's no easy way around this. It 
> should give you output once there are packages to update: 
>
> # zypper --quiet --non-interactive up 
>
> The following 6 NEW packages are going to be installed: 
>   dbus-1 kbd kmod pinentry pkg-config udev 
>
> The following 56 packages are going to be upgraded: 
>   aaa_base acl bash blog ca-certificates-mozilla cpio file [...] 
>
> The following product is going to be reinstalled: 
>   "openSUSE Leap 42.3" 
>
> 56 packages to upgrade, 6 new. 
> Overall download size: 27.8 MiB. Already cached: 0 B. After the operation, 
> additional 12.4 MiB will be used. 
> Continue? [y/n/...? shows all options] (y): y 
>
> Regards 
> -- 
> Sebastian Meyer 
> Linux Consultant & Trainer 
> Mail: me...@b1-systems.de  
>
> B1 Systems GmbH 
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de 
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537 
>

-- 
This e-mail message (including any attachments) is for the sole use of the 
intended recipient(s) and may contain confidential, privileged, and/or 
proprietary information. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this message (including any attachments) is strictly prohibited.


If you have received this message in error, please contact the sender by 
reply e-mail message and destroy all copies of the original message 
(including attachments).

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/06d0d78d-03e3-4319-a4ef-32b01e77f7f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Sebastian Meyer
Hi,

On 13.06.19 23:50, Bobby Hood wrote:
>"cmd": [ 
>"/usr/bin/zypper",  
>"--quiet",  

the ansible zypper module calls zypper with --quiet, as you can check on
the commandline that leads to zypper not writing to stdout, if there's
nothing to do:

# zypper update
Loading repository data...
Reading installed packages...

Nothing to do.
#
# zypper --quiet update
#

As this is hardcoded in the module, there's no easy way around this. It
should give you output once there are packages to update:

# zypper --quiet --non-interactive up

The following 6 NEW packages are going to be installed:
  dbus-1 kbd kmod pinentry pkg-config udev

The following 56 packages are going to be upgraded:
  aaa_base acl bash blog ca-certificates-mozilla cpio file [...]

The following product is going to be reinstalled:
  "openSUSE Leap 42.3"

56 packages to upgrade, 6 new.
Overall download size: 27.8 MiB. Already cached: 0 B. After the operation,
additional 12.4 MiB will be used.
Continue? [y/n/...? shows all options] (y): y

Regards
-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9b9731f9-f099-7e15-b48a-28ea858eda9f%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Bobby Hood
Still having some trouble with this. I changed the registered variables to 
apt_result and zypper_result:

- name: (SuSE) Update all packages to latest versions 
  when: ansible_os_family == "Suse" 
  zypper: 
name: '*' 
state: latest 
type: package 
update_cache: yes 
  register: zypper_result 
- name: (Debian) Update all packages to latest versions 
  when: ansible_os_family == "Debian" 
  apt: 
name: '*' 
state: latest 
update_cache: yes 
force_apt_get: yes 
autoremove: yes 
  register: apt_result


But the zypper module returns completely different parameters than the apt 
module. Shouldn't it contain stdout and stderr too? I've tried removing all 
the apt stuff to eliminate any conflicts but the results didn't change. 
This is the zypper_result variable dump. It runs zypper update just fine on 
the host but I'm not getting the return values I want. At minimum I need 
the stdout and stderr output.

ok: [raamah] => { 
   "zypper_result": { 
   "changed": false,  
   "cmd": [ 
   "/usr/bin/zypper",  
   "--quiet",  
   "--non-interactive",  
   "--xmlout",  
   "update",  
   "--type",  
   "package",  
   "--auto-agree-with-licenses",  
   "--no-recommends" 
   ],  
   "failed": false,  
   "name": [ 
   "*" 
   ],  
   "rc": 0,  
   "state": "latest",  
   "update_cache": true 
   } 
}

The apt dump again:

ok: [webtest01] => { 
   "apt_result": { 
   "changed": false,  
   "failed": false,  
   "msg": "Reading package lists...\nBuilding dependency 
tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
0 newly installed, 0 to remove and 0 not upgraded.\n", 
   
   "stderr": "",  
   "stderr_lines": [],  
   "stdout": "Reading package lists...\nBuilding dependency 
tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
0 newly installed, 0 to remove and 0 not upgraded.\n", 

   "stdout_lines": [ 
   "Reading package lists...",  
   "Building dependency tree...",  
   "Reading state information...",  
   "Calculating upgrade...",  
   "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." 
   ] 
   } 
}

On Thursday, June 13, 2019 at 10:45:08 AM UTC-6, Bobby Hood wrote:

> Ah I see, thank you.
>
> On Thursday, June 13, 2019 at 10:38:16 AM UTC-6, Matt Martz wrote:
>>
>> You are registering to the same variable in both tasks.  Ansible will 
>> register regardless of the task being skipped or not.
>>
>> If the suse/zypper task executes, I assume that the apt task should skip, 
>> as such, the zypper task registered with real data first, and then the apt 
>> task overwrites the result with a skipped info.
>>
>> You should be using different register variable names for each task, to 
>> avoid this issue.
>>
>> On Thu, Jun 13, 2019 at 11:23 AM Bobby Hood  wrote:
>>
>>> I'm using the zypper and apt modules to update remote hosts. I don't 
>>> know if I'm missing something or it's a bug, but registering a variable in 
>>> the zypper module is getting skipped. It works fine in the apt module.
>>>
>>> - name: (SuSE) Update all packages to latest versions
>>>   when: ansible_os_family == "Suse"
>>>   *zy*pper:
>>> name: '*'
>>> state: latest
>>> type: package
>>> update_cache: yes
>>>   register: update_result
>>> - name: (Debian) Update all packages to latest versions
>>>   when: ansible_os_family == "Debian"
>>>   apt:
>>> name: '*'
>>> state: latest
>>> update_cache: yes
>>> force_apt_get: yes
>>> autoremove: yes
>>>   register: update_result
>>>
>>>
>>>
>>> This is the variable dump when using zypper. It's always *"changed": 
>>> false* and *"skipped": true* even if changes are made.
>>>
>>> ok: [raamah] => { 
>>>"update_result": { 
>>>"changed": false,  
>>>"skip_reason": "Conditional result was False",  
>>>"skipped": true 
>>>} 
>>> }
>>>
>>>
>>> However, the apt module always returns values for "msg", "stderr", and 
>>> "stdout" as seen below. Am I using the zypper module incorrectly or 
>>> something?
>>>
>>> ok: [webtest01] => { 
>>>"update_result": { 
>>>"changed": false,  
>>>"failed": false,  
>>>"msg": "Reading package lists...\nBuilding dependency 
>>> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
>>> 0 newly installed, 0 to remove and 0 not upgraded.\n", 
>>>
>>>"stderr": "",  
>>>"stderr_lines": [],  
>>>"stdout": "Reading package lists...\nBuilding dependency 
>>> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
>>> 0 newly installed, 0 to remove a

Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Bobby Hood
Ah I see, thank you.

On Thursday, June 13, 2019 at 10:38:16 AM UTC-6, Matt Martz wrote:
>
> You are registering to the same variable in both tasks.  Ansible will 
> register regardless of the task being skipped or not.
>
> If the suse/zypper task executes, I assume that the apt task should skip, 
> as such, the zypper task registered with real data first, and then the apt 
> task overwrites the result with a skipped info.
>
> You should be using different register variable names for each task, to 
> avoid this issue.
>
> On Thu, Jun 13, 2019 at 11:23 AM Bobby Hood > 
> wrote:
>
>> I'm using the zypper and apt modules to update remote hosts. I don't know 
>> if I'm missing something or it's a bug, but registering a variable in the 
>> zypper module is getting skipped. It works fine in the apt module.
>>
>> - name: (SuSE) Update all packages to latest versions
>>   when: ansible_os_family == "Suse"
>>   *zy*pper:
>> name: '*'
>> state: latest
>> type: package
>> update_cache: yes
>>   register: update_result
>> - name: (Debian) Update all packages to latest versions
>>   when: ansible_os_family == "Debian"
>>   apt:
>> name: '*'
>> state: latest
>> update_cache: yes
>> force_apt_get: yes
>> autoremove: yes
>>   register: update_result
>>
>>
>>
>> This is the variable dump when using zypper. It's always *"changed": 
>> false* and *"skipped": true* even if changes are made.
>>
>> ok: [raamah] => { 
>>"update_result": { 
>>"changed": false,  
>>"skip_reason": "Conditional result was False",  
>>"skipped": true 
>>} 
>> }
>>
>>
>> However, the apt module always returns values for "msg", "stderr", and 
>> "stdout" as seen below. Am I using the zypper module incorrectly or 
>> something?
>>
>> ok: [webtest01] => { 
>>"update_result": { 
>>"changed": false,  
>>"failed": false,  
>>"msg": "Reading package lists...\nBuilding dependency 
>> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
>> 0 newly installed, 0 to remove and 0 not upgraded.\n", 
>>
>>"stderr": "",  
>>"stderr_lines": [],  
>>"stdout": "Reading package lists...\nBuilding dependency 
>> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
>> 0 newly installed, 0 to remove and 0 not upgraded.\n", 
>> 
>>"stdout_lines": [ 
>>"Reading package lists...",  
>>"Building dependency tree...",  
>>"Reading state information...",  
>>"Calculating upgrade...",  
>>"0 upgraded, 0 newly installed, 0 to remove and 0 not 
>> upgraded." 
>>] 
>>} 
>> }
>>
>> This e-mail message (including any attachments) is for the sole use of 
>> the intended recipient(s) and may contain confidential, privileged, and/or 
>> proprietary information. If the reader of this message is not the intended 
>> recipient, you are hereby notified that any dissemination, distribution or 
>> copying of this message (including any attachments) is strictly prohibited.
>>
>> If you have received this message in error, please contact the sender by 
>> reply e-mail message and destroy all copies of the original message 
>> (including attachments).
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/6029dc73-1bdb-4623-92d4-a59801c9f029%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
This e-mail message (including any attachments) is for the sole use of the 
intended recipient(s) and may contain confidential, privileged, and/or 
proprietary information. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this message (including any attachments) is strictly prohibited.


If you have received this message in error, please contact the sender by 
reply e-mail message and destroy all copies of the original message 
(including attachments).

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view th

Re: [ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Matt Martz
You are registering to the same variable in both tasks.  Ansible will
register regardless of the task being skipped or not.

If the suse/zypper task executes, I assume that the apt task should skip,
as such, the zypper task registered with real data first, and then the apt
task overwrites the result with a skipped info.

You should be using different register variable names for each task, to
avoid this issue.

On Thu, Jun 13, 2019 at 11:23 AM Bobby Hood  wrote:

> I'm using the zypper and apt modules to update remote hosts. I don't know
> if I'm missing something or it's a bug, but registering a variable in the
> zypper module is getting skipped. It works fine in the apt module.
>
> - name: (SuSE) Update all packages to latest versions
>   when: ansible_os_family == "Suse"
>   *zy*pper:
> name: '*'
> state: latest
> type: package
> update_cache: yes
>   register: update_result
> - name: (Debian) Update all packages to latest versions
>   when: ansible_os_family == "Debian"
>   apt:
> name: '*'
> state: latest
> update_cache: yes
> force_apt_get: yes
> autoremove: yes
>   register: update_result
>
>
>
> This is the variable dump when using zypper. It's always *"changed":
> false* and *"skipped": true* even if changes are made.
>
> ok: [raamah] => {
>"update_result": {
>"changed": false,
>"skip_reason": "Conditional result was False",
>"skipped": true
>}
> }
>
>
> However, the apt module always returns values for "msg", "stderr", and
> "stdout" as seen below. Am I using the zypper module incorrectly or
> something?
>
> ok: [webtest01] => {
>"update_result": {
>"changed": false,
>"failed": false,
>"msg": "Reading package lists...\nBuilding dependency
> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded,
> 0 newly installed, 0 to remove and 0 not upgraded.\n",
>
>"stderr": "",
>"stderr_lines": [],
>"stdout": "Reading package lists...\nBuilding dependency
> tree...\nReading state information...\nCalculating upgrade...\n0 upgraded,
> 0 newly installed, 0 to remove and 0 not upgraded.\n",
>
>"stdout_lines": [
>"Reading package lists...",
>"Building dependency tree...",
>"Reading state information...",
>"Calculating upgrade...",
>"0 upgraded, 0 newly installed, 0 to remove and 0 not
> upgraded."
>]
>}
> }
>
> This e-mail message (including any attachments) is for the sole use of the
> intended recipient(s) and may contain confidential, privileged, and/or
> proprietary information. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, distribution or
> copying of this message (including any attachments) is strictly prohibited.
>
> If you have received this message in error, please contact the sender by
> reply e-mail message and destroy all copies of the original message
> (including attachments).
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6029dc73-1bdb-4623-92d4-a59801c9f029%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9rKzs2BCrwN2nBJVBq0Y3c0CcER7em-x3yNm2tHPTjVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Variable registration is getting skipped in zypper module

2019-06-13 Thread Bobby Hood
I'm using the zypper and apt modules to update remote hosts. I don't know 
if I'm missing something or it's a bug, but registering a variable in the 
zypper module is getting skipped. It works fine in the apt module.

- name: (SuSE) Update all packages to latest versions
  when: ansible_os_family == "Suse"
  *zy*pper:
name: '*'
state: latest
type: package
update_cache: yes
  register: update_result
- name: (Debian) Update all packages to latest versions
  when: ansible_os_family == "Debian"
  apt:
name: '*'
state: latest
update_cache: yes
force_apt_get: yes
autoremove: yes
  register: update_result



This is the variable dump when using zypper. It's always *"changed": false*
 and *"skipped": true* even if changes are made.

ok: [raamah] => { 
   "update_result": { 
   "changed": false,  
   "skip_reason": "Conditional result was False",  
   "skipped": true 
   } 
}


However, the apt module always returns values for "msg", "stderr", and 
"stdout" as seen below. Am I using the zypper module incorrectly or 
something?

ok: [webtest01] => { 
   "update_result": { 
   "changed": false,  
   "failed": false,  
   "msg": "Reading package lists...\nBuilding dependency 
tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
0 newly installed, 0 to remove and 0 not upgraded.\n", 
   
   "stderr": "",  
   "stderr_lines": [],  
   "stdout": "Reading package lists...\nBuilding dependency 
tree...\nReading state information...\nCalculating upgrade...\n0 upgraded, 
0 newly installed, 0 to remove and 0 not upgraded.\n", 

   "stdout_lines": [ 
   "Reading package lists...",  
   "Building dependency tree...",  
   "Reading state information...",  
   "Calculating upgrade...",  
   "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." 
   ] 
   } 
}

-- 
This e-mail message (including any attachments) is for the sole use of the 
intended recipient(s) and may contain confidential, privileged, and/or 
proprietary information. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this message (including any attachments) is strictly prohibited.


If you have received this message in error, please contact the sender by 
reply e-mail message and destroy all copies of the original message 
(including attachments).

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6029dc73-1bdb-4623-92d4-a59801c9f029%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.