I just do it with:
group_vars/relevantgroup:
httpd_rpm: httpd # if you aren't fussy - this will get you the latest
at the time of the first run
# or : httpd_rpm: http-2.0.36 # if you want a specific version
task looks like :
- name: install {{ httpd_rpm }}
yum: name={{ httpd_rpm }} state=present
In my experience, state=latest is probably a Bad Idea in the config
management world
- packages changing underneath you either
a) should reload the service (potentially causing an outage) or
b) don't reload the service (almost definitely storing up trouble at
next reboot)
in both cases there's also the risk that a config file default will
change and ruin your day.
On 24 October 2014 14:19, Gaston Acosta <[email protected]> wrote:
> Hi all,
>
> I resolve this using something like this:
>
> yum: pkg=httpd-{{ httpd_version | default('*') }} state=latest
> as the documentation says :
> "Package name, or package specifier with version, like name-1.0. When using
> state=latest, this can be '*' which means run: yum -y update. You can also
> pass a url or a local path to a rpm file."
>
> Hope that helps
>
> El miércoles, 21 de agosto de 2013 08:27:09 UTC-3, Byron Schlemmer escribió:
>>
>> Hi all,
>>
>> I'm trying to work out the best way to either install the latest version
>> or a specified version of a package dependent on a group_vars variable
>> passed.
>>
>> That is, my group_vars/group contains:
>>
>> mypackage: 1.0
>>
>> But it could be changed to
>>
>> mypackage: latest
>>
>> And I want package installation to occur accordingly.
>>
>> My play has:
>>
>> - name: install mypackage rpm
>> yum: name=mypackage state=latest
>> when: mypackage_version == "latest"
>>
>> - name: install mypackage rpm
>> yum: name=mypackage-{{ mypackage_version }} state=installed
>> when: mypackage_version != "latest"
>>
>> Now this works but I end up with output from both packages:
>>
>> TASK: [install mypackage rpm]
>> ****************************************
>> ok: [myhost00]
>>
>> TASK: [install mypackage rpm]
>> ****************************************
>> skipping: [myhost00]
>>
>> Is there a way to silence the output on the task that did not run? Is this
>> the best way to accomplish this or should I abstract with an include in some
>> fashion?
>>
>> Thanks,
>>
>>
> --
> 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/c8ebc35e-6158-4810-8483-cfd90a125082%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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/CAK5eLPTs7GWk8ricECnSmkJ9T9kp6p536vKf7PbE4sGRXW6%3DjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.