Hi,

have started evaluating ansible playbook functionality to perform
simple config management tasks.

I have experienced several problems. Tried to get some help on irc,
and through web searches, but.. well. I'm here :)

I'm running the following playbook:

-------8<-------
# test.yml
---
- hosts: all
  become: yes
  tasks:

  - name: Install hoardr-client for RedHat/CentOS
    yum: "name={{ item }} state=installed"
    with_items:
      - hoardr-client
    when: ansible_pkg_mgr == 'yum'

  - name: Install hoardr-client for Debian/Ubuntu
    apt: "name={{ item }} update_cache=yes"
    with_items:
      - hoardr-client
    when: ansible_pkg_mgr == 'apt'
-------8<-------

(more on this playbook later)

What happens is that the "when:" condition seems to fail
miserably (wrapping is likely to destroy this, so
http://pastebin.com/YtcNuxnj holds the original):

-------8<-------
# Running: ansible-playbook test.yml
TASK [Install hoardr-client for RedHat/CentOS]
*********************************
fatal: [localhost.localdomain]: FAILED! => {
    "failed": true,
    "msg": "The conditional check 'ansible_pkg_mgr == 'yum'' failed.
            The error was: error while evaluating conditional
(ansible_pkg_mgr == 'yum'): 'ansible_pkg_mgr' is undefined
            The error appears to have been in
'/home/cosimo/src/sys/ansible/test.yml': line 9, column 5, but may
            be elsewhere in the file depending on the exact syntax problem.
            The offending line appears to be:
              - name: Install hoardr-client for RedHat/CentOS
                ^ here"}
    to retry, use: --limit @/home/cosimo/src/sys/ansible/test.retry
-------8<-------

I traced this back to facts gathering not working for some reason.
Next step I tried:

    ansible -m setup <hostname> | grep ansible_pkg_mgr
        "ansible_pkg_mgr": "apt",

it would seem the answer I got was correct,
so what is going wrong here?

Side notes:

1) searching around, I found instances of the following syntax:

     when: "'$ansible_pkg_mgr' == 'yum'"

   This is not working either. I hope this is on purpose :-)

2) I found a `package' directive, which I'd really wish I could use,
   instead of yum/apt alternate code paths. When I try it,
   I get the following error message:

   ... cannot detect which package manager to use: try gathering facts
   or setting the "use" option.

   What is the "use" option? I can't seem to find it anywhere.

Thanks for at least reading through this,

-- 
Cosimo

-- 
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/9bf7850e-53ad-f63b-0e38-3859f2ca62db%40streppone.it.
For more options, visit https://groups.google.com/d/optout.

Reply via email to