From 0dde125863f28d39daca2de9ccdef3ac1cb388a0 Mon Sep 17 00:00:00 2001 From: Martin Kulich Date: Mon, 5 Oct 2020 08:43:41 +0200 Subject: [PATCH 1/4] Enable creating custom confs --- README.md | 3 +++ defaults/main.yml | 3 +++ tasks/manage_confs.yml | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index c87eece..14ebd19 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,9 @@ Here is a list of all the default variables for this role, which are also availa # apache2_confs: # - { id: security, state: absent } # - { name: mime, state: present } +# - id: my_config +# state: present +# template: path/to/template.j2 # apache2_sites: # - id: mysite (required) # name: mysite.local (required) diff --git a/defaults/main.yml b/defaults/main.yml index fee2572..53071ac 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,6 +8,9 @@ # apache2_confs: # - { id: security, state: absent } # - { name: mime, state: present } +# - id: my_config +# state: present +# template: path/to/template.j2 # apache2_sites: # - id: mysite (required) # name: mysite.local (required) diff --git a/tasks/manage_confs.yml b/tasks/manage_confs.yml index 4801699..a289d49 100644 --- a/tasks/manage_confs.yml +++ b/tasks/manage_confs.yml @@ -1,5 +1,16 @@ --- +- name: Creating confs + template: + src: "{{ item.template }}" + dest: "/etc/apache2/conf-available/{{ item.id }}.conf" + owner: root + group: root + mode: "0644" + when: item.template is defined + with_items: "{{ apache2_confs }}" + notify: reload apache2 + - name: Enabling conf command: > a2enconf {{ item.id }} From 467dbc9e70ac88f8403647ba24d5c2fe6d876c96 Mon Sep 17 00:00:00 2001 From: franklin Date: Fri, 6 Nov 2020 16:06:09 +0100 Subject: [PATCH 2/4] chore: add vscode settings --- .gitignore | 4 +++- .vscode/extensions.json | 5 +++++ .vscode/settings.json | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 61f047a..62f2449 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ *.retry .DS_Store .vagrant -.vscode +.vscode/* +!.vscode/settings.json +!.vscode/extensions.json .idea diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..dd8f125 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscoss.vscode-ansible" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..237ad63 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.yml": "ansible" + } +} From 399ebb83c8658295e4fb837d2399fe474ba0f229 Mon Sep 17 00:00:00 2001 From: franklin Date: Fri, 6 Nov 2020 16:08:20 +0100 Subject: [PATCH 3/4] updating notification --- tasks/manage_confs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/manage_confs.yml b/tasks/manage_confs.yml index 521739c..b47b495 100644 --- a/tasks/manage_confs.yml +++ b/tasks/manage_confs.yml @@ -9,7 +9,7 @@ mode: "0644" when: item.template is defined with_items: "{{ apache2_confs }}" - notify: reload apache2 + notify: test and reload apache2 - name: Enabling conf command: > From 8e07b39a92e8c98d0aa687857f035b2abfafd1eb Mon Sep 17 00:00:00 2001 From: franklin Date: Fri, 6 Nov 2020 16:08:41 +0100 Subject: [PATCH 4/4] chore: updating makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1d592a1..e504d2c 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ PWD=$(shell pwd) ROLE_NAME=weareinteractive.apache2 ROLE_PATH=/etc/ansible/roles/$(ROLE_NAME) TEST_VERSION=ansible --version -TEST_DEPS=ansible-galaxy install -c weareinteractive.apt weareinteractive.openssl weareinteractive.htpasswd +TEST_DEPS=apt-get update && apt-get install -y python3-pip && pip3 install pyopenssl && ansible-galaxy install -c weareinteractive.apt weareinteractive.openssl weareinteractive.htpasswd TEST_SYNTAX=ansible-playbook -v -i 'localhost,' -c local $(ROLE_PATH)/tests/main.yml --syntax-check -TEST_PLAYBOOK=ansible-playbook -vvvv -i 'localhost,' -c local $(ROLE_PATH)/tests/main.yml +TEST_PLAYBOOK=ansible-playbook -vvvv -i 'localhost,' -c local -e 'ansible_python_interpreter=/usr/bin/python3' $(ROLE_PATH)/tests/main.yml TEST_IDEMPOTENT=$(TEST_PLAYBOOK) | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1) -TEST_CMD=$(TEST_VERSION); $(TEST_SYNTAX); $(TEST_DEPS); $(TEST_PLAYBOOK); $(TEST_IDEMPOTENT) +TEST_CMD=$(TEST_DEPS); $(TEST_VERSION); $(TEST_SYNTAX); $(TEST_PLAYBOOK); $(TEST_IDEMPOTENT) docs: ansible-role docgen