On 18. nov. 2016 20:17, [email protected] wrote:
   - name: Subscribing a new channel
     shell: sh -c "sudo yum clean all"
   - shell: sh -c "sudo rhnreg_ks --activationkey 1-vblock20161026"
   - shell: sh -c "sudo rhnreg_ks --activationkey 1-vblock20161026 --force"

[snip]

TASK [Subscribing a new channel]
***********************************************
changed: [ccltstftsmrk1]

TASK [command]
*****************************************************************
fatal: [ccltstftsmrk1]: FAILED! => {"changed": true, "cmd": "sh -c \"sudo
rhnreg_ks --activationkey 1-vblock20161026\"", "delta": "0:00:00.270108",
"end": "2016-11-18 14:06:44.477886", "failed": true, "rc": 255, "start":
"2016-11-18 14:06:44.207778", "stderr": "", "stdout": "This system is
already registered. Use --force to override", "stdout_lines": ["This system
is already registered. Use --force to override"], "warnings": []}

It's failing on the first rhnreg_ks that doesn't have --force because it's already registered. It this circumstance rhnreg_ks return code is 255, everything higher than 0 is a failure for the shell module.
You can change this behavior with the failed_when.

Have you checked out these two module, maybe they can do what you are trying to do?

rhn_register - Manage Red Hat Network registration using the rhnreg_ks command
rhn_channel - Adds or removes Red Hat software channels

--
Kai Stian Olstad

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/53a957ac-bce3-9c71-5863-33758e8a7ee8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to