As we have to manage a mixed environment, we do have different
packagemanagers.
So I often use when clauses like this
when: ansible_pkg_mgr == "apt"
I really like facts to be available in my playbooks.
So my goal is/was to avoid running raw yum commands against a debian or
apt against Red Hat in our global site playbook.
A other thing I want to avoid is having a complicated documentation
about which playbook to run against a server.
I am dreaming of a one-size-fits-all playbook :-)
Will the shell module work if the install of python-simplejson is required?
At least for the install of python (Minimal debian does not have it) I
need to go for raw.
On 04/17/2014 04:23 AM, Michael DeHaan wrote:
You are definitely overcomplicating it.
There's no reason to need the register really.
- shell: yum -y install python-simplejson
Yum naturally is smart enough to not do anything if the package is
already installed, so it takes care of the "idempotence" (I kinda
still hate the over-complexity of that word, but it's a word) for you.
On Wed, Apr 16, 2014 at 1:36 AM, Christian Rusa
<[email protected] <mailto:[email protected]>> wrote:
To be honest, I would also be interested in a solution to this.
Of course all the machines, that I install myself (preseed,
kickstart, ...) meet the requirements for ansible.
For already existing machines which should be managed by us, the
requirements are somewhere in the middle of met or unmet.
To my knowledge python-simplejson (required on Python 2.4 boxes)
can only be installed using the raw module and not with the apt or
yum module.
Therefore this is a task which I'd not like to be executed on
every run.
Maybe the first task in the list could be an ansible ping and if
it fails do some brute-force raw commands.
....
And as writing this I answered my question :-)
My prototype looks like this:
- hosts: all
user: root
tasks:
- name: ping
ping:
register: result
- name: conditional task
raw: here_your_command
when: result|failed
Cheers
Christian
On 04/15/2014 05:34 PM, Dick Davies wrote:
On 15 April 2014 09:24, Joachim Friberg <[email protected]
<mailto:[email protected]>> wrote:
For example I want to do a yum install mysql on a server,
but this server
does not have python-simplejson and/or other packages that
is neccesary for
Ansible.
In this specific case you'd just assert the python-simplejson
package
exists right?
If it's already installed then nothing happens, and you'll be
able to
skip on to the
other tasks.
If of course you're in a catch-22 situation (can't run ansible
to set
up ansible pre-requisites),
then you'll need to seed your base image with what's required.
For example, my kickstarts bring up a machine with
* SSHd enabled and tcp/22 inbound permitted on the local firewall
* an 'ansible' account with a pre-defined list of SSH keys in its
authorised_keys file
* passwordless sudo configured for that account
Everything else is managed by Ansible.
This general approach also applies to CM with puppet, chef, etc.
(which typically
have much more requirements).
--
toscom - the open source company
Christian Rusa
Breiteneckergasse 32 1230 Wien
Mobil: 0699 10205595 Fax: 01 9249633
www.toscom.at <http://www.toscom.at> [email protected]
<mailto:[email protected]>
--
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]
<mailto:ansible-project%[email protected]>.
To post to this group, send email to
[email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/534E16E8.1050305%40toscom.at.
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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzxqTe_VgyjAXpz81FVzBfTbrfAjUyCKFZtZPYo0jfjKA%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzxqTe_VgyjAXpz81FVzBfTbrfAjUyCKFZtZPYo0jfjKA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
toscom - the open source company
Christian Rusa
Breiteneckergasse 32 1230 Wien
Mobil: 0699 10205595 Fax: 01 9249633
www.toscom.at [email protected]
--
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/534F762C.5090603%40toscom.at.
For more options, visit https://groups.google.com/d/optout.