Bertrand Lanson
8c9bdfbea5
All checks were successful
development / Check commit compliance (push) Successful in 5s
test / Retrieve Credentials (pull_request) Successful in 1s
pull-requests-open / Check commit compliance (pull_request) Successful in 5s
test / end_to_end_role (default, debian11) (pull_request) Successful in 39s
test / end_to_end_role (default, debian12) (pull_request) Successful in 38s
test / end_to_end_role (default, ubuntu2004) (pull_request) Successful in 40s
test / end_to_end_role (default, ubuntu2204) (pull_request) Successful in 39s
test / end_to_end_role (default, ubuntu2404) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, debian11) (pull_request) Successful in 38s
test / end_to_end_role (with_custom_flags, debian12) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2004) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2204) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2404) (pull_request) Successful in 40s
This also adjusts the unit.j2 template accordingly, as well as update documentation for the role. It also updates tests to cover more scenarios
85 lines
3.4 KiB
YAML
85 lines
3.4 KiB
YAML
---
|
|
- name: Verify
|
|
hosts: all
|
|
gather_facts: true
|
|
become: true
|
|
tasks:
|
|
- name: "Test: file /etc/default/nginx"
|
|
block:
|
|
- name: "Stat file /etc/default/nginx"
|
|
ansible.builtin.stat:
|
|
path: "/etc/default/nginx"
|
|
register: stat_etc_default_nginx
|
|
|
|
- name: "Slurp file /etc/default/nginx"
|
|
ansible.builtin.slurp:
|
|
src: "/etc/default/nginx"
|
|
register: slurp_etc_default_nginx
|
|
|
|
- name: "Verify file /etc/default/nginx"
|
|
vars:
|
|
nginx_expected_env_file: |
|
|
TEST_ENV=test
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_etc_default_nginx.stat.exists
|
|
- stat_etc_default_nginx.stat.isreg
|
|
- stat_etc_default_nginx.stat.pw_name == 'root'
|
|
- stat_etc_default_nginx.stat.gr_name == 'root'
|
|
- stat_etc_default_nginx.stat.mode == '0600'
|
|
- (slurp_etc_default_nginx.content|b64decode) == nginx_expected_env_file
|
|
|
|
- name: "Test: service nginx_container"
|
|
block:
|
|
- name: "Get service nginx_container"
|
|
ansible.builtin.service_facts:
|
|
|
|
- name: "Stat file /etc/systemd/system/nginx_container.service"
|
|
ansible.builtin.stat:
|
|
path: "/etc/systemd/system/nginx_container.service"
|
|
register: stat_etc_systemd_system_nginx_container_service
|
|
|
|
- name: "Slurp file /etc/systemd/system/nginx_container.service"
|
|
ansible.builtin.slurp:
|
|
src: "/etc/systemd/system/nginx_container.service"
|
|
register: slurp_etc_systemd_system_nginx_container_service
|
|
|
|
- name: "Verify service nginx_container"
|
|
vars:
|
|
nginx_expected_service_file: |
|
|
# Ansible managed: Do NOT edit this file manually!
|
|
[Unit]
|
|
Requires=multi-user.target
|
|
After=docker.service
|
|
PartOf=docker.service
|
|
|
|
[Service]
|
|
EnvironmentFile=/etc/default/nginx
|
|
ExecStartPre=-/usr/bin/docker rm -f nginx
|
|
ExecStart=/usr/bin/docker run --name nginx \
|
|
--rm \
|
|
--env-file /etc/default/nginx \
|
|
--privileged \
|
|
--network "host" \
|
|
--cap-add "NET_ADMIN" \
|
|
nginx:1.27
|
|
ExecStop=/usr/bin/docker stop nginx
|
|
SyslogIdentifier=nginx
|
|
Restart=always
|
|
RestartSec=10s
|
|
|
|
[Install]
|
|
WantedBy=docker.service
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_etc_systemd_system_nginx_container_service.stat.exists
|
|
- stat_etc_systemd_system_nginx_container_service.stat.isreg
|
|
- stat_etc_systemd_system_nginx_container_service.stat.pw_name == 'root'
|
|
- stat_etc_systemd_system_nginx_container_service.stat.gr_name == 'root'
|
|
- stat_etc_systemd_system_nginx_container_service.stat.mode == '0644'
|
|
- (slurp_etc_systemd_system_nginx_container_service.content|b64decode) == nginx_expected_service_file
|
|
- ansible_facts.services['nginx_container.service'] is defined
|
|
- ansible_facts.services['nginx_container.service']['source'] == 'systemd'
|
|
- ansible_facts.services['nginx_container.service']['state'] == 'inactive'
|
|
- ansible_facts.services['nginx_container.service']['status'] == 'enabled'
|