Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expand uninstall support #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
- plus
- upgrade
- modules
- uninstall
- uninstall-module
- plus-count-ubuntu
- plus-count-rhel
- plus-count-upgrade
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Working functional playbook examples can be found in the **[`molecule/`](https:/
| **[`plus/converge.yml`](https://github.com/nginxinc/ansible-role-nginx-management-suite/blob/main/molecule/plus/converge.yml)** | Install NGINX Plus and NMS |
| **[`upgrade/converge.yml`](https://github.com/nginxinc/ansible-role-nginx-management-suite/blob/main/molecule/upgrade/converge.yml)** | Upgrade NMS |
| **[`modules/converge.yml`](https://github.com/nginxinc/ansible-role-nginx-management-suite/blob/main/molecule/modules/converge.yml)** | Install NGINX OSS and NMS & the API Connectivity Manager module |
| **[`uninstall/converge.yml`](https://github.com/nginxinc/ansible-role-nginx-management-suite/blob/main/molecule/uninstall/converge.yml)** | Uninstall NMS |

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-management-suite` to `nginxinc.nginx_management_suite`.

Expand Down
17 changes: 17 additions & 0 deletions molecule/uninstall-module/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Converge
hosts: all
tasks:
- name: Uninstall NMS ACM Module
ansible.builtin.include_role:
name: ansible-role-nginx-management-suite
vars:
nms_user_passwd: 'Password123'
nms_remove_certs: false
nginx_remove_license: false
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
nms_modules:
- name: acm
setup: uninstall
112 changes: 112 additions & 0 deletions molecule/uninstall-module/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
driver:
name: docker
lint: |
set -e
ansible-lint --force-color .
platforms:
- name: amazonlinux-2
image: amazonlinux:2
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: oraclelinux-7
image: oraclelinux:7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: oraclelinux-8
image: oraclelinux:8
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: centos-7
image: centos:7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-8
image: redhat/ubi8:8.7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: debian-buster
image: debian:buster-slim
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: debian-bullseye
image: debian:bullseye-slim
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-bionic
image: ubuntu:bionic
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-focal
image: ubuntu:focal
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-jammy
image: ubuntu:jammy
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
provisioner:
name: ansible
playbooks:
prepare: prepare.yml
converge: converge.yml
verify: verify.yml
35 changes: 35 additions & 0 deletions molecule/uninstall-module/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
- name: Prepare License
hosts: localhost
gather_facts: false
tasks:
- name: Create ephemeral license certificate file from b64 decoded env var # noqa template-instead-of-copy
ansible.builtin.copy:
content: "{{ lookup('env', 'NGINX_CRT') | b64decode }}"
dest: ../../files/license/nginx-repo.crt
force: false
mode: "0444"

- name: Create ephemeral license key file from b64 decoded env var # noqa template-instead-of-copy
ansible.builtin.copy:
content: "{{ lookup('env', 'NGINX_KEY') | b64decode }}"
dest: ../../files/license/nginx-repo.key
force: false
mode: "0444"

- name: Prepare NMS
hosts: all
tasks:
- name: Install NMS & ACM Module
ansible.builtin.include_role:
name: ansible-role-nginx-management-suite
vars:
nms_setup: install
nms_user_passwd: 'Password123'
nginx_remove_license: false
nms_remove_certs: false
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
nms_modules:
- name: acm
46 changes: 46 additions & 0 deletions molecule/uninstall-module/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: Verify
hosts: all
tasks:
- name: Check if NGINX is installed
ansible.builtin.package:
name: nginx
state: present
check_mode: true
register: install
failed_when: (install is changed) or (install is failed)

- name: Check if NGINX service is running
ansible.builtin.service:
name: nginx
state: started
enabled: true
check_mode: true
register: service
failed_when: (service is changed) or (service is failed)

- name: Verify NGINX is up and running
ansible.builtin.uri:
url: http://localhost
status_code: 200

- name: Check if NGINX Management Suite services are still running
ansible.builtin.systemd:
name: "{{ item }}"
state: running
check_mode: true
register: install
failed_when: (install is changed) or (install is failed)
loop:
- nms
- nms-core
- nms-dpm
- nms-ingestion
- nms-integrations

- name: Check if NGINX Management Suite Module services are no longer installed
ansible.builtin.service_facts:
register: systemd_services
failed_when: item in systemd_services.ansible_facts.services
loop:
- nms-acm.service
15 changes: 15 additions & 0 deletions molecule/uninstall/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Converge
hosts: all
tasks:
- name: Uninstall NMS
ansible.builtin.include_role:
name: ansible-role-nginx-management-suite
vars:
nms_setup: uninstall
nms_user_passwd: 'Password123'
nms_remove_certs: false
nginx_remove_license: false
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
112 changes: 112 additions & 0 deletions molecule/uninstall/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
driver:
name: docker
lint: |
set -e
ansible-lint --force-color .
platforms:
- name: amazonlinux-2
image: amazonlinux:2
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: oraclelinux-7
image: oraclelinux:7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: oraclelinux-8
image: oraclelinux:8
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: centos-7
image: centos:7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-7
image: registry.access.redhat.com/ubi7/ubi:7.9
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: rhel-8
image: redhat/ubi8:8.7
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /usr/sbin/init
- name: debian-buster
image: debian:buster-slim
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: debian-bullseye
image: debian:bullseye-slim
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-bionic
image: ubuntu:bionic
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-focal
image: ubuntu:focal
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
- name: ubuntu-jammy
image: ubuntu:jammy
platform: x86_64
dockerfile: ../common/Dockerfile.j2
privileged: true
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
command: /sbin/init
provisioner:
name: ansible
playbooks:
prepare: prepare.yml
converge: converge.yml
verify: verify.yml
33 changes: 33 additions & 0 deletions molecule/uninstall/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Prepare License
hosts: localhost
gather_facts: false
tasks:
- name: Create ephemeral license certificate file from b64 decoded env var # noqa template-instead-of-copy
ansible.builtin.copy:
content: "{{ lookup('env', 'NGINX_CRT') | b64decode }}"
dest: ../../files/license/nginx-repo.crt
force: false
mode: "0444"

- name: Create ephemeral license key file from b64 decoded env var # noqa template-instead-of-copy
ansible.builtin.copy:
content: "{{ lookup('env', 'NGINX_KEY') | b64decode }}"
dest: ../../files/license/nginx-repo.key
force: false
mode: "0444"

- name: Prepare NMS
hosts: all
tasks:
- name: Install NMS
ansible.builtin.include_role:
name: ansible-role-nginx-management-suite
vars:
nms_setup: install
nms_user_passwd: 'Password123'
nginx_remove_license: false
nms_remove_certs: false
nginx_license:
certificate: license/nginx-repo.crt
key: license/nginx-repo.key
Loading