034_rols
This commit is contained in:
11
examples/034_rols/playbooks/hostname.yml
Normal file
11
examples/034_rols/playbooks/hostname.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Ping to servers
|
||||
ping:
|
||||
- name: Get hostname
|
||||
command: hostname
|
||||
register: hostname
|
||||
- name: Show hostname with message
|
||||
debug:
|
||||
msg: "The hostname of this server is {{ hostname.stdout }}"
|
||||
33
examples/034_rols/playbooks/stack_restart.yml
Normal file
33
examples/034_rols/playbooks/stack_restart.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
# Bring stack down
|
||||
- hosts: loadbalancer
|
||||
become: true
|
||||
tasks:
|
||||
- service: name=nginx state=stopped
|
||||
- wait_for: port=80 state=drained
|
||||
|
||||
- hosts: webserver
|
||||
become: true
|
||||
tasks:
|
||||
- service: name=apache2 state=stopped
|
||||
- wait_for: port=80 state=stopped
|
||||
|
||||
# Restart mysql
|
||||
- hosts: database
|
||||
become: true
|
||||
tasks:
|
||||
- service: name=mysql state=restarted
|
||||
- wait_for: port=3306 state=started
|
||||
|
||||
# Bring stack up
|
||||
- hosts: webserver
|
||||
become: true
|
||||
tasks:
|
||||
- service: name=apache2 state=started
|
||||
- wait_for: port=80
|
||||
|
||||
- hosts: loadbalancer
|
||||
become: true
|
||||
tasks:
|
||||
- service: name=nginx state=started
|
||||
- wait_for: port=80
|
||||
70
examples/034_rols/playbooks/stack_status.yml
Normal file
70
examples/034_rols/playbooks/stack_status.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
- hosts: loadbalancer
|
||||
become: true
|
||||
tasks:
|
||||
- name: verify nginx service
|
||||
command: service nginx status
|
||||
|
||||
- name: verify nginx is listening on 80
|
||||
wait_for: port=80 timeout=1
|
||||
|
||||
- hosts: webserver
|
||||
become: true
|
||||
tasks:
|
||||
- name: verify apache2 service
|
||||
command: service apache2 status
|
||||
|
||||
- name: verify apache2 is listening on 80
|
||||
wait_for: port=80 timeout=1
|
||||
|
||||
- hosts: database
|
||||
become: true
|
||||
tasks:
|
||||
- name: verify mysql service
|
||||
command: service mysql status
|
||||
|
||||
- name: verify mysql is listening on 3306
|
||||
wait_for: port=3306 timeout=1
|
||||
|
||||
- hosts: loadbalancer
|
||||
tasks:
|
||||
- name: verify backend index response
|
||||
uri: url=http://{{item}} return_content=yes
|
||||
loop: "{{ groups.webserver }}"
|
||||
register: app_index
|
||||
|
||||
- fail: msg="index failed to return content"
|
||||
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||
loop: "{{app_index.results}}"
|
||||
|
||||
- name: verify backend db response
|
||||
uri: url=http://{{item}}/db return_content=yes
|
||||
loop: "{{ groups.webserver }}"
|
||||
register: app_db
|
||||
|
||||
- fail: msg="db failed to return content"
|
||||
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||
loop: "{{app_db.results}}"
|
||||
|
||||
- hosts: control
|
||||
tasks:
|
||||
- name: get elements from loadbalancer group
|
||||
debug: var=groups.loadbalancer
|
||||
|
||||
- name: verify end-to-end connectivity to loadbalancer
|
||||
uri: url=http://{{item}} return_content=yes
|
||||
loop: "{{ groups.loadbalancer }}"
|
||||
register: lb_connectivity
|
||||
|
||||
- fail: msg="index failed to return content"
|
||||
when: ("Hello, from sunny " ~ item.content ~ "!") in item.content
|
||||
loop: "{{lb_connectivity.results}}"
|
||||
|
||||
- name: verify end-to-end db response
|
||||
uri: url=http://{{item}}/db return_content=yes
|
||||
loop: "{{ groups.loadbalancer }}"
|
||||
register: lb_db
|
||||
|
||||
- fail: msg="db failed to return content"
|
||||
when: ("Database Connected from " ~ item.content ~ "!") in item.content
|
||||
loop: "{{lb_db.results}}"
|
||||
Reference in New Issue
Block a user