Skip to content

Instantly share code, notes, and snippets.

---
- hosts: webserver
become: true
tasks:
- name: install epel
yum: name="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" state=present
- name: install web components
yum: name={{item}} state=present
with_items:
- httpd
[opc@vm04 ansible]$ ansible-playbook webserver.yml
PLAY [webserver] ***************************************************************
TASK [setup] *******************************************************************
ok: [129.146.32.41]
ok: [129.146.20.198]
TASK [install epel] ************************************************************
ok: [129.146.32.41]
[opc@vm04 ansible]$ vi webserver.yml
---
- hosts: webserver
become: true
tasks:
- name: install epel
yum: name="https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" state=present
- name: install web components
yum: name={{item}} state=present
[opc@vm04 ansible]$ ansible-playbook webserver.yml
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/home/opc/ansible/webserver.yml': line 17, column 8, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: ensure mod_wsgi enabled
[opc@db01 ~]$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
INPUT_direct all -- anywhere anywhere
INPUT_ZONES_SOURCE all -- anywhere anywhere
INPUT_ZONES all -- anywhere anywhere
DROP all -- anywhere anywhere ctstate INVALID
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
[opc@vm04 ansible]$ ansible-playbook webserver.yml
PLAY [webserver] ***************************************************************
TASK [setup] *******************************************************************
ok: [129.146.32.41]
ok: [129.146.20.198]
TASK [install web components] **************************************************
failed: [129.146.20.198] (item=[u'httpd', u'libhttpd-mod-wsgi']) => {"changed": false, "failed": true, "item": ["httpd", "libhttpd-mod-wsgi"], "msg": "No package matching 'libhttpd-mod-wsgi' found available, installed or updated", "rc": 126, "results": ["httpd-2.4.6-45.0.1.el7_3.4.x86_64 providing httpd is already installed", "No package matching 'libhttpd-mod-wsgi' found available, installed or updated"]}
---
- hosts: webserver
become: true
tasks:
- name: install web components
yum: name={{item}} state=present
with_items:
- httpd
- libapache2-mod-wsgi
- python-pip
---
- hosts: database
become: true
tasks:
- name: install mysql-server
yum: name="http://dev.mysql.com/get/mysql-community-relea-el7-5.noarch.rpm" state=present
- name: install mysql-server
yum: name=mysql-server state=present
[opc@vm04 ansible]$ ansible-playbook database.yml
PLAY [database] ****************************************************************
TASK [setup] *******************************************************************
ok: [129.146.23.42]
TASK [install mysql-server] ****************************************************
fatal: [129.146.23.42]: FAILED! => {"changed": false, "failed": true, "msg": "Failure downloading http://dev.mysql.com/get/mysql-community-relea-el7-5.noarch.rpm, 'NoneType' object has no attribute 'read'"}
to retry, use: --limit @/home/opc/ansible/database.retry
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml
PLAY [loadbalancer] ************************************************************
TASK [setup] *******************************************************************
ok: [129.146.34.164]
TASK [install epel] ************************************************************
changed: [129.146.34.164]