From 253a21432ee229a46b729d7661454e163817cc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Tue, 15 Nov 2022 23:05:52 +0100 Subject: [PATCH] Add ssl_certs_enabled variable and use it to avoid ssl certs when running on vagrant --- playbook.yml | 5 ++++- roles/docker/tasks/services/mailu.yml | 3 ++- roles/docker/tasks/services/nginx-proxy.yml | 1 + roles/ubuntu_base/tasks/main.yml | 4 +--- roles/ubuntu_base/tasks/virtualization.yml | 4 ---- 5 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 roles/ubuntu_base/tasks/virtualization.yml diff --git a/playbook.yml b/playbook.yml index 949ebd3..fe20a09 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,12 +1,15 @@ --- - hosts: all - gather_facts: false + gather_facts: true become: true vars: base_domain: data.coop letsencrypt_email: admin@data.coop ldap_dn: "dc=data,dc=coop" + vagrant: "{{ ansible_virtualization_role == 'guest' }}" + ssl_certs_enabled: "{{ vagrant == false }}" + services: - nginx-proxy - postfix diff --git a/roles/docker/tasks/services/mailu.yml b/roles/docker/tasks/services/mailu.yml index e53d92c..04f8a80 100644 --- a/roles/docker/tasks/services/mailu.yml +++ b/roles/docker/tasks/services/mailu.yml @@ -28,7 +28,7 @@ dest: "{{ mailu.volume_folder }}/certs/cert.pem" state: hard force: yes - + when: ssl_certs_enabled - name: hard link to Let's Encrypt TLS key file: @@ -36,6 +36,7 @@ dest: "{{ mailu.volume_folder }}/certs/key.pem" state: hard force: yes + when: ssl_certs_enabled - name: run mail server containers docker_compose: diff --git a/roles/docker/tasks/services/nginx-proxy.yml b/roles/docker/tasks/services/nginx-proxy.yml index bf9fa90..490b65f 100644 --- a/roles/docker/tasks/services/nginx-proxy.yml +++ b/roles/docker/tasks/services/nginx-proxy.yml @@ -44,4 +44,5 @@ - /var/run/docker.sock:/var/run/docker.sock:ro env: NGINX_PROXY_CONTAINER: nginx-proxy + when: ssl_certs_enabled diff --git a/roles/ubuntu_base/tasks/main.yml b/roles/ubuntu_base/tasks/main.yml index d21a74f..7313caa 100644 --- a/roles/ubuntu_base/tasks/main.yml +++ b/roles/ubuntu_base/tasks/main.yml @@ -1,11 +1,9 @@ --- - import_tasks: ssh-port.yml tags: [change-ssh-port] -- import_tasks: virtualization.yml - tags: [gather-virtualization-facts] - import_tasks: dell-apt-repo.yml tags: [setup-dell-apt-repo] - when: ansible_virtualization_role != "guest" + when: vagrant == false - import_tasks: upgrade.yml tags: [do-full-system-upgrade] - import_tasks: base.yml diff --git a/roles/ubuntu_base/tasks/virtualization.yml b/roles/ubuntu_base/tasks/virtualization.yml deleted file mode 100644 index 0315499..0000000 --- a/roles/ubuntu_base/tasks/virtualization.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: Determine if running in a VM - setup: - gather_subset: virtualization_role