Hi all,
I noticed that using "yum: name='@group'" always results in "changed"
even when the group has already been installed. Is there a way to get
"ok" when nothing needs to be done?
Cheers,
Hilco
Hi all,
I noticed that using "yum: name='@group'" always results in "changed"
even when the group has already been installed. Is there a way to get
"ok" when nothing needs to be done?
Cheers,
Hilco
Yum groups are a bit of a weird thing in yum API land.
It looks like we don’t have a ticket open on this one - if you’d like to file one, we’d appreciate it.
(Particularly notable tip about yum groups, never uninstall a yum group – it does not do what you think in yum and may uninstall dependencies you wish to keep).
Done: https://github.com/ansible/ansible/issues/9030 .
What do I do in the meantime? Is there a workaround?
Not really a good one, no.
Perhaps install the packages you need instead of a group, or ignore the changed state.
I want to rely on the state to (conditionally) execute other things so
ignoring is not an option. Installing all the packages individually
does work even if it is rather clumsy and not very maintenance
friendly.
Perhaps you can use a 'register' in your task to get the results which can then be used as a condition in a 'when' statement in the next task?
Here's the content of a register var when a group is already installed:
TASK: [debug var=yum_results] ***
ok: [test.local] => {
"yum_results": {
"changed": true,
"invocation": {
"module_args": "name='@development' state=latest",
"module_name": "yum"
},
"msg": "",
"rc": 0,
"results": [
"No packages marked for update\n"
]
}
}
In the next task use a 'when' condition that "No packaged marked for update" should be <what you need>:
- name: next task
yum: name=otherpackage state=latest
when: yum_results.results.find('No packages marked for update') = -1
The 'when' statement is untested and just to give an idea. More here:
http://docs.ansible.com/playbooks_conditionals.html#register-variables
HTH,
Patrick