Skip to content

Commit

Permalink
feat: allow custom confs
Browse files Browse the repository at this point in the history
Merge branch 'InstruktoriBrno-custom_config' into master
  • Loading branch information
franklinkim committed Nov 6, 2020
2 parents 737fb2d + 8e07b39 commit 34bb6b1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
*.retry
.DS_Store
.vagrant
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
.idea
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"vscoss.vscode-ansible"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.yml": "ansible"
}
}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tasks/manage_confs.yml
Original file line number Diff line number Diff line change
@@ -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: test and reload apache2

- name: Enabling conf
command: >
a2enconf {{ item.id }}
Expand Down

0 comments on commit 34bb6b1

Please sign in to comment.