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
gather_facts: true
gather_facts: false
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
@ -36,9 +33,19 @@
smtp_port: "587"
tasks:
- import_role:
name: ssh_and_vagrant
tags:
- base_only
- setup_services
- import_role:
name: ubuntu_base
vars:
vagrant: "{{ ansible_virtualization_role == 'guest' }}"
tags:
- base_only
- import_role:
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"
state: hard
force: yes
when: ssl_certs_enabled
when: letsencrypt_enabled
- name: hard link to Let's Encrypt TLS key
file:
@ -36,7 +36,7 @@
dest: "{{ mailu.volume_folder }}/certs/key.pem"
state: hard
force: yes
when: ssl_certs_enabled
when: letsencrypt_enabled
- name: run mail server containers
docker_compose:

View file

@ -44,5 +44,5 @@
- /var/run/docker.sock:/var/run/docker.sock:ro
env:
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
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
set_fact:
ansible_port: 22
@ -22,7 +22,7 @@
- name: Change SSH port on host
lineinfile:
dest: "/etc/ssh/sshd_config"
regexp: "^#?Port"
regexp: "^#?Port "
line: "Port 19022"
register: ssh_changed
notify: "Restart sshd"

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
apt:
name: srvadmin-all
when: ansible_virtualization_role != "guest"
when: not vagrant
- name: Install necessary packages via pip
pip:

View file

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