Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit f239c39

Browse files
authored
Merge pull request #239 from jcsmith/cleanup_lamp_simple
Fix ansible-lint reported errors and update syntax in lamp_simple.
2 parents 13f8624 + 0d102e5 commit f239c39

File tree

7 files changed

+75
-22
lines changed

7 files changed

+75
-22
lines changed

lamp_simple/roles/common/handlers/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.
44

55
- name: restart ntp
6-
service: name=ntpd state=restarted
6+
service:
7+
name: ntpd
8+
state: restarted

lamp_simple/roles/common/tasks/main.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
# This playbook contains common plays that will be run on all nodes.
33

44
- name: Install ntp
5-
yum: name=ntp state=present
5+
yum:
6+
name: ntp
7+
state: present
68
tags: ntp
79

810
- name: Configure ntp file
9-
template: src=ntp.conf.j2 dest=/etc/ntp.conf
11+
template:
12+
src: ntp.conf.j2
13+
dest: /etc/ntp.conf
1014
tags: ntp
1115
notify: restart ntp
1216

1317
- name: Start the ntp service
14-
service: name=ntpd state=started enabled=yes
18+
service:
19+
name: ntpd
20+
state: started
21+
enabled: yes
1522
tags: ntp
1623

1724
- name: test to see if selinux is running

lamp_simple/roles/db/handlers/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# Handler to handle DB tier notifications
33

44
- name: restart mysql
5-
service: name=mysqld state=restarted
5+
service:
6+
name: mysqld
7+
state: restarted
68

79
- name: restart iptables
8-
service: name=iptables state=restarted
10+
service:
11+
name: iptables
12+
state: restarted

lamp_simple/roles/db/tasks/main.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,53 @@
22
# This playbook will install mysql and create db user and give permissions.
33

44
- name: Install Mysql package
5-
yum: name={{ item }} state=installed
5+
yum:
6+
name: "{{ item }}"
7+
state: installed
68
with_items:
79
- mysql-server
810
- MySQL-python
911
- libselinux-python
1012
- libsemanage-python
1113

1214
- name: Configure SELinux to start mysql on any port
13-
seboolean: name=mysql_connect_any state=true persistent=yes
15+
seboolean:
16+
name: mysql_connect_any
17+
state: true
18+
persistent: yes
1419
when: sestatus.rc != 0
1520

1621
- name: Create Mysql configuration file
17-
template: src=my.cnf.j2 dest=/etc/my.cnf
22+
template:
23+
src: my.cnf.j2
24+
dest: /etc/my.cnf
1825
notify:
1926
- restart mysql
2027

2128
- name: Start Mysql Service
22-
service: name=mysqld state=started enabled=yes
29+
service:
30+
name: mysqld
31+
state: started
32+
enabled: yes
2333

2434
- name: insert iptables rule
25-
lineinfile: dest=/etc/sysconfig/iptables state=present regexp="{{ mysql_port }}"
26-
insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport {{ mysql_port }} -j ACCEPT"
35+
lineinfile:
36+
dest: /etc/sysconfig/iptables
37+
state: present
38+
regexp: "{{ mysql_port }}"
39+
insertafter: "^:OUTPUT "
40+
line: "-A INPUT -p tcp --dport {{ mysql_port }} -j ACCEPT"
2741
notify: restart iptables
2842

2943
- name: Create Application Database
30-
mysql_db: name={{ dbname }} state=present
44+
mysql_db:
45+
name: "{{ dbname }}"
46+
state: present
3147

3248
- name: Create Application DB User
33-
mysql_user: name={{ dbuser }} password={{ upassword }} priv=*.*:ALL host='%' state=present
49+
mysql_user:
50+
name: "{{ dbuser }}"
51+
password: "{{ upassword }}"
52+
priv: "*.*:ALL"
53+
host: '%'
54+
state: present

lamp_simple/roles/web/handlers/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.
44

55
- name: restart iptables
6-
service: name=iptables state=restarted
6+
service:
7+
name: iptables
8+
state: restarted

lamp_simple/roles/web/tasks/copy_code.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# the version control system.
44

55
- name: Copy the code from repository
6-
git: repo={{ repository }} dest=/var/www/html/
6+
git:
7+
repo: "{{ repository }}"
8+
dest: /var/www/html/
79

810
- name: Creates the index.php file
9-
template: src=index.php.j2 dest=/var/www/html/index.php
11+
template:
12+
src: index.php.j2
13+
dest: /var/www/html/index.php

lamp_simple/roles/web/tasks/install_httpd.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# These tasks install http and the php modules.
33

44
- name: Install http and php etc
5-
yum: name={{ item }} state=present
5+
yum:
6+
name: "{{ item }}"
7+
state: present
68
with_items:
79
- httpd
810
- php
@@ -12,13 +14,24 @@
1214
- libselinux-python
1315

1416
- name: insert iptables rule for httpd
15-
lineinfile: dest=/etc/sysconfig/iptables create=yes state=present regexp="{{ httpd_port }}" insertafter="^:OUTPUT "
16-
line="-A INPUT -p tcp --dport {{ httpd_port }} -j ACCEPT"
17+
lineinfile:
18+
dest: /etc/sysconfig/iptables
19+
create: yes
20+
state: present
21+
regexp: "{{ httpd_port }}"
22+
insertafter: "^:OUTPUT "
23+
line: "-A INPUT -p tcp --dport {{ httpd_port }} -j ACCEPT"
1724
notify: restart iptables
1825

1926
- name: http service state
20-
service: name=httpd state=started enabled=yes
27+
service:
28+
name: httpd
29+
state: started
30+
enabled: yes
2131

2232
- name: Configure SELinux to allow httpd to connect to remote database
23-
seboolean: name=httpd_can_network_connect_db state=true persistent=yes
33+
seboolean:
34+
name: httpd_can_network_connect_db
35+
state: true
36+
persistent: yes
2437
when: sestatus.rc != 0

0 commit comments

Comments
 (0)