Skip to content

Instantly share code, notes, and snippets.

View 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
with_items:
- httpd
View error output
[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]
View webserver.yml
[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
View output
[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
View gist:5ec2b03134ce13983876c0e553e1dae4
[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
View gist:7359c51cc120aae13a99af67db8dd4cb
[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"]}
View gist:7379ea3a25b379ddb68b846476d162dd
---
- hosts: webserver
become: true
tasks:
- name: install web components
yum: name={{item}} state=present
with_items:
- httpd
- libapache2-mod-wsgi
- python-pip
View database.yml
---
- 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
View output
[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
View gist:838bd0a7ffe9b39ee746ec109f4bd976
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml
PLAY [loadbalancer] ************************************************************
TASK [setup] *******************************************************************
ok: [129.146.34.164]
TASK [install epel] ************************************************************
changed: [129.146.34.164]