Skip to content

Commit 730ab15

Browse files
authored
Replace Molecule's Python verifier with the Ansible verifier (#285)
1 parent e9b6c59 commit 730ab15

File tree

36 files changed

+215
-288
lines changed

36 files changed

+215
-288
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ before_install:
6363
install:
6464
- pip install ansible==2.9.9
6565
- pip install molecule[docker]==3.0.4
66-
- pip install testinfra
6766
- pip install ansible-lint
68-
- pip install flake8
6967
script:
7068
- molecule --version
7169
- ansible --version

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ Example Playbooks
195195

196196
Working functional playbook examples can be found in the **`molecule/common`** directory in the following files:
197197

198-
- **[molecule/common/playbook_default.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_default.yml):** Install a specific version of NGINX and set up logrotate
199-
- **[molecule/common/playbook_module.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_module.yml):** Install various NGINX supported modules
200-
- **[molecule/common/playbook_source.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_source.yml):** Install NGINX from source
201-
- **[molecule/common/playbook_stable_push.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_stable_push.yml):** Install NGINX using the stable branch and push a preexisting config from your system to your NGINX instance
202-
- **[molecule/common/playbook_template.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_template.yml):** Use the NGINX configuration templating variables to create an NGINX configuration file
203-
- **[molecule/common/playbook_unit.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbook_unit.yml):** Install NGINX Unit
198+
- **[molecule/common/playbooks/default_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/default_converge.yml):** Install a specific version of NGINX and set up logrotate
199+
- **[molecule/common/playbooks/module_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/module_converge.yml):** Install various NGINX supported modules
200+
- **[molecule/common/playbooks/source_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/source_converge.yml):** Install NGINX from source
201+
- **[molecule/common/playbooks/stable_push_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/stable_push_converge.yml):** Install NGINX using the stable branch and push a preexisting config from your system to your NGINX instance
202+
- **[molecule/common/playbooks/template_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/template_converge.yml):** Use the NGINX configuration templating variables to create an NGINX configuration file
203+
- **[molecule/common/playbooks/unit_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/molecule/common/playbooks/unit_converge.yml):** Install NGINX Unit
204204

205205
Do note that if you install this repository via Ansible Galaxy, you will have to replace the role variable in the sample playbooks from `ansible-role-nginx` to `nginxinc.nginx`.
206206

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX is installed
6+
package:
7+
name: nginx
8+
check_mode: yes
9+
register: install
10+
failed_when: (install is changed) or (install is failed)
11+
12+
- name: Check if NGINX service is running
13+
service:
14+
name: nginx
15+
state: started
16+
enabled: yes
17+
check_mode: yes
18+
register: service
19+
failed_when: (service is changed) or (service is failed)
20+
21+
- name: Verify NGINX is up and running
22+
uri:
23+
url: http://localhost
24+
status_code: 200
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX is installed
6+
package:
7+
name: nginx
8+
check_mode: yes
9+
register: install
10+
failed_when: (install is changed) or (install is failed)
11+
12+
- name: Check if NGINX service is running
13+
service:
14+
name: nginx
15+
state: started
16+
enabled: yes
17+
check_mode: yes
18+
register: service
19+
failed_when: (service is changed) or (service is failed)
20+
21+
- name: Check default.conf does not exist
22+
stat:
23+
path: /etc/nginx/conf.d/default.conf
24+
register: stat_result
25+
failed_when: stat_result.stat.exists
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX service is running
6+
service:
7+
name: nginx
8+
state: started
9+
enabled: yes
10+
check_mode: yes
11+
register: service
12+
failed_when: (service is changed) or (service is failed)
13+
14+
- name: Verify NGINX is up and running
15+
uri:
16+
url: http://localhost
17+
status_code: 200

molecule/common/playbook_stable_push.yml renamed to molecule/common/playbooks/stable_push_converge.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
nginx_branch: stable
1010
nginx_main_upload_enable: true
11-
nginx_main_upload_src: files/nginx.conf
11+
nginx_main_upload_src: ../files/nginx.conf
1212
nginx_http_upload_enable: true
13-
nginx_http_upload_src: files/http/*.conf
13+
nginx_http_upload_src: ../files/http/*.conf
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX is installed
6+
package:
7+
name: nginx
8+
check_mode: yes
9+
register: install
10+
failed_when: (install is changed) or (install is failed)
11+
12+
- name: Check if NGINX service is running
13+
service:
14+
name: nginx
15+
state: started
16+
enabled: yes
17+
check_mode: yes
18+
register: service
19+
failed_when: (service is changed) or (service is failed)
20+
21+
- name: Verify NGINX is up and running
22+
uri:
23+
url: http://localhost
24+
status_code: 200
25+
26+
- name: Check default.conf exists
27+
stat:
28+
path: /etc/nginx/conf.d/default.conf
29+
register: stat_result
30+
failed_when: not stat_result.stat.exists
31+
32+
- name: Ensure default.conf contains 'location /'
33+
lineinfile:
34+
path: /etc/nginx/conf.d/default.conf
35+
line: " location / {"
36+
state: present
37+
check_mode: yes
38+
register: conf
39+
failed_when: (conf is changed) or (conf is failed)

0 commit comments

Comments
 (0)