Vagrant-based testing environment #111

Merged
valberg merged 15 commits from vagrant into main 2022-11-25 13:07:10 +00:00
9 changed files with 27 additions and 13 deletions
Showing only changes of commit 57ca1e9233 - Show all commits

View file

@ -1,15 +1,12 @@
--- ---
- hosts: all - hosts: all
gather_facts: true gather_facts: false
become: true become: true
vars: vars:
base_domain: data.coop base_domain: data.coop
letsencrypt_email: admin@data.coop letsencrypt_email: admin@data.coop
ldap_dn: "dc=data,dc=coop" ldap_dn: "dc=data,dc=coop"
vagrant: "{{ ansible_virtualization_role == 'guest' }}"
ssl_certs_enabled: "{{ vagrant == false }}"
services: services:
- nginx-proxy - nginx-proxy
- postfix - postfix
@ -36,9 +33,19 @@
smtp_port: "587" smtp_port: "587"
tasks: tasks:
- import_role:
name: ssh_and_vagrant
tags:
- base_only
- setup_services
- import_role: - import_role:
name: ubuntu_base name: ubuntu_base
vars:
vagrant: "{{ ansible_virtualization_role == 'guest' }}"
tags: tags:
- base_only - base_only
- import_role: - import_role:
name: docker name: docker
vars:
vagrant: "{{ ansible_virtualization_role == 'guest' }}"
letsencrypt_enabled: "{{ not vagrant }}"

View file

@ -28,7 +28,7 @@
dest: "{{ mailu.volume_folder }}/certs/cert.pem" dest: "{{ mailu.volume_folder }}/certs/cert.pem"
state: hard state: hard
force: yes force: yes
when: ssl_certs_enabled when: letsencrypt_enabled
- name: hard link to Let's Encrypt TLS key - name: hard link to Let's Encrypt TLS key
file: file:
@ -36,7 +36,7 @@
dest: "{{ mailu.volume_folder }}/certs/key.pem" dest: "{{ mailu.volume_folder }}/certs/key.pem"
state: hard state: hard
force: yes force: yes
when: ssl_certs_enabled when: letsencrypt_enabled
- name: run mail server containers - name: run mail server containers
docker_compose: docker_compose:

View file

@ -44,5 +44,5 @@
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
env: env:
NGINX_PROXY_CONTAINER: nginx-proxy NGINX_PROXY_CONTAINER: nginx-proxy
when: ssl_certs_enabled when: letsencrypt_enabled

View file

@ -0,0 +1,5 @@
---
- import_tasks: ssh-port.yml
tags: [change-ssh-port]
- import_tasks: virtualization.yml
tags: [gather-virtualization-facts]

View file

@ -11,7 +11,7 @@
ignore_errors: true ignore_errors: true
register: ssh_configured register: ssh_configured
# If we're running in Vagrant, ansible_port is 2222 # If running in Vagrant, ansible_port is always 2222
- name: Change Ansible port to 22 if needed - name: Change Ansible port to 22 if needed
set_fact: set_fact:
ansible_port: 22 ansible_port: 22

View file

@ -0,0 +1,4 @@
---
- name: Determine if running in Vagrant
setup:
gather_subset: virtualization_role

View file

@ -13,7 +13,7 @@
- name: Install Dell OpenManage - name: Install Dell OpenManage
apt: apt:
name: srvadmin-all name: srvadmin-all
when: ansible_virtualization_role != "guest" when: not vagrant
- name: Install necessary packages via pip - name: Install necessary packages via pip
pip: pip:

View file

@ -1,9 +1,7 @@
--- ---
- import_tasks: ssh-port.yml
tags: [change-ssh-port]
- import_tasks: dell-apt-repo.yml - import_tasks: dell-apt-repo.yml
tags: [setup-dell-apt-repo] tags: [setup-dell-apt-repo]
when: vagrant == false when: not vagrant
- import_tasks: upgrade.yml - import_tasks: upgrade.yml
tags: [do-full-system-upgrade] tags: [do-full-system-upgrade]
- import_tasks: base.yml - import_tasks: base.yml