Hello,
I’ve been using ansible for a few months now and got around to reorganizing my playbooks according to the current best practices recently. I’ve created a host_vars folder at the top level and put a file in there named after the system (fqdn). This his how it’s defined in the hosts file, and is also the hostname of the server.
I have defined something like:
You have issues with “true” being loaded as a Boolean.
change this to:
when: ads_mount
and you should be fine
When you say "Now if I change it to “when: ads_mount is defined” in both locations, the first task works but mount is still skipped. ", I am skeptical here, and would need to see the playbook. I suspect you have something slightly different with the second part, as that should not be the case and is somewhat impossible
I’ll try the change tonight.
I changed the server names below, but otherwise this is the content. The reason I include add_app_mounts.yml in main.yml rather than just put the entries in main.yml are that I’m going to be adding a number of things to both files and it seemed cleaner to me to have main.yml be a lot of includes, and each “config” grouping be an include.
Top level folder: hosts, host_vars/, playbook, roles/
Slight change to below, the >0 was when I tried changing the host_vars to set to 0 and 1 rather than true and false…right now
they say:
when: ads_mount == “true”
which I will change to be just “when: ads_mount” as suggested and try it.
Although with “ads_mount: 1” and “when: ads_mount > 0” set, I got the same behavior, the folder exists task fired, the mount was skipped.
Bob
Here’s the output of the run with “when: ads_mount”
PLAY [Setup Servers] *****************************************
GATHERING FACTS ***************************************************************
ok: [system.domain.com]
TASK: [Ensure /opt/ads folder exits] ******************************************
ok: [system.domain.com]
TASK: [Mount /opt/ads] ********************************************************
skipping: [system.domain.com]
TASK: [Ensure /opt/altera folder exists] **************************************
ok: [system.domain.com]
TASK: [Mount /opt/altera] *****************************************************
skipping: [system.domain.com]
Can you pastebin your playbook where you have this set?
Yeah, please use gist for something like this if you want.
I generally do not read attachments to the mailing list, and would request that folks don’t send attachments.
It has 1000s of subscribers.
Sorry…
https://gist.github.com/rlbeaver/ece9bf8c35c0b4d18c12
I deleted my post, not that it matters with the email distribution.
Looks correct as a boolean, I’m curious.
Please make sure there is a bug report referencing this ticket so I can put it in the queue of things to reproduce.
Thanks!
Will do, to add to it, I’ve set “ostype: rhel6” in host_vars, and I don’t want to treat it as boolean, so I’m doing the "when: ostype == “rhel6”’ after some actions and others would have "when: ostype == “rhel5”. The first action is executed, the following are all skipped, but it identifies the second action…
I added another file to the gist to show…
Think I figured out what I was seeing. I was using the --check option to the ansible-playbook command and probably missed the documentation that indicated that some commands would be skipped (which makes sense since they can’t be “tested”.) Sorry for the confusion.