diff --git a/README.md b/README.md index e1cbfd3..5321d05 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,11 @@ Setup ```bash ansible-galaxy install -r requirements.yml -ansible-galaxy collection install community.general ``` Call with ```bash -ansible-playbook -i inventory httpd.yml +ansible-playbook -i inventory --ask-vault-pass main.yml ``` -You need to provide a user with sudo rights. +You need to provide a user with sudo rights and the vault password. diff --git a/main.yml b/main.yml index 2b25a4e..008a3ad 100644 --- a/main.yml +++ b/main.yml @@ -50,10 +50,16 @@ include_tasks: tasks/users.yml - name: Install Docker - include_tasks: tasks/docker_install.yml + include_role: + name: install-docker + vars: + docker_users: "{{ admin_users }}" - - name: Setup Docker Containers - include_tasks: tasks/docker_setup.yml + - name: Setup Docker Environment + include_tasks: tasks/docker_env.yml - name: Setup httpd include_tasks: tasks/httpd.yml + + - name: Setup phpmyadmin + include_tasks: tasks/phpmyadmin.yml diff --git a/roles/install-docker/handlers/main.yml b/roles/install-docker/handlers/main.yml new file mode 100644 index 0000000..4e8c5a0 --- /dev/null +++ b/roles/install-docker/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: restart docker + service: + name: docker + state: restarted + enabled: yes diff --git a/tasks/docker_install.yml b/roles/install-docker/tasks/main.yml similarity index 91% rename from tasks/docker_install.yml rename to roles/install-docker/tasks/main.yml index 38c91bf..4590f0a 100644 --- a/tasks/docker_install.yml +++ b/roles/install-docker/tasks/main.yml @@ -55,14 +55,7 @@ "max-size": "100m" } } - register: docker_config - -- name: Restart docker for changed configuration - service: - name: docker - state: restarted - enabled: yes - when: docker_config.changed + notify: restart docker - name: Check current docker-compose version. command: docker-compose --version @@ -89,4 +82,4 @@ name: "{{ item }}" groups: docker append: yes - with_items: "{{ admin_users }}" + with_items: "{{ docker_users }}" diff --git a/tasks/docker_env.yml b/tasks/docker_env.yml new file mode 100644 index 0000000..3e05570 --- /dev/null +++ b/tasks/docker_env.yml @@ -0,0 +1,10 @@ +- name: Setup docker network + docker_network: + name: dockernet + driver: bridge + ipam_config: + - subnet: 192.168.0.0/24 + gateway: 192.168.0.1 + state: present + + diff --git a/tasks/httpd.yml b/tasks/httpd.yml index 1f8ac4c..8e9aa27 100644 --- a/tasks/httpd.yml +++ b/tasks/httpd.yml @@ -10,12 +10,7 @@ name: rewrite state: present -- name: Setup proxy site mysql.adm.netz39.de - include_role: - name: setup-http-site-proxy - vars: - site_name: mysql.adm.netz39.de - proxy_port: 9001 + - name: Setup proxy site testredmine.netz39.de include_role: diff --git a/tasks/docker_setup.yml b/tasks/phpmyadmin.yml similarity index 68% rename from tasks/docker_setup.yml rename to tasks/phpmyadmin.yml index 59fdb63..c9e0a09 100644 --- a/tasks/docker_setup.yml +++ b/tasks/phpmyadmin.yml @@ -1,12 +1,4 @@ -- name: Setup docker network - docker_network: - name: dockernet - driver: bridge - ipam_config: - - subnet: 192.168.0.0/24 - gateway: 192.168.0.1 - state: present - +--- - name: Setup phpmyadmin docker_container: name: phpmyadmin @@ -22,3 +14,10 @@ PMA_ABSOLUTE_URI: "https://mysql.adm.netz39.de" published_ports: - 9001:80 + +- name: Setup proxy site mysql.adm.netz39.de + include_role: + name: setup-http-site-proxy + vars: + site_name: mysql.adm.netz39.de + proxy_port: 9001