August 2015
Intermediate to advanced
168 pages
3h 32m
English
The Nginx role that we created earlier to set up web server supports only Debian-based systems. Running this logic on other systems could lead to failure. For example, the Nginx role uses the apt module to install packages, which would not work on RedHat-based systems, which depend on the yum package manager. This could be avoided by adding the when statement with a fact to selectively execute based on an OS family. The following is the snippet from the www.yml playbook:
#filename: www.yml (snippet)
- hosts: www
roles:
- { role: nginx, when: ansible_os_family == 'Debian' }Read now
Unlock full access