Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vignesh-v3/5c4c964f56ffb56ccdd187ba1785bd1b to your computer and use it in GitHub Desktop.
Save vignesh-v3/5c4c964f56ffb56ccdd187ba1785bd1b to your computer and use it in GitHub Desktop.
what is the problem here
testu@ubuntu:~/playbooks/new$ cat when.yml
---
- hosts: fedora
gather_facts: no
tasks:
- name: install apache to appropriate distro to ubuntu
command: apt-get -y install apache2
when: ansible_os_family == "Debian"
- name: Install apache appropriate to rhel or centro
command: yum -y install http
when: ansible_os_family == "RedHat"
testu@ubuntu:~/playbooks/new$ ansible-playbook when.yml -b
PLAY [fedora] ******************************************************************
TASK [install apache to appropriate distro to ubuntu] **************************
fatal: [192.168.198.130]: FAILED! => {"failed": true, "msg": "The conditional check 'ansible_os_family == \"Debian\"' failed. The error was: error while evaluating conditional (ansible_os_family == \"Debian\"): 'ansible_os_family' is undefined\n\nThe error appears to have been in '/home/testu/playbooks/new/when.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: install apache to appropriate distro to ubuntu\n ^ here\n"}
[WARNING]: Could not create retry file '/home/testu/playbooks/new/when.retry'.
[Errno 13] Permission denied: u'/home/testu/playbooks/new/when.retry'
PLAY RECAP *********************************************************************
192.168.198.130 : ok=0 changed=0 unreachable=0 failed=1
@vishnus
Copy link

vishnus commented Sep 12, 2017

Remove "gather_facts: no" and try.. It should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment