Vagrant-based testing environment #111

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

16
Vagrantfile vendored
View file

@ -1,7 +1,11 @@
Vagrant.require_version ">= 1.7.0" Vagrant.require_version ">= 1.7.0"
PORT = 19022
Vagrant.configure(2) do |config| Vagrant.configure(2) do |config|
config.vm.network "forwarded_port", guest: 19022, host: 19022, id: "new_ssh" config.vm.network :forwarded_port, guest: PORT, host: PORT, id: "new_ssh"
# If we are trying to SSH into the VM, we need to use the new port
if ARGV[0] == "ssh"
config.ssh.guest_port = PORT
end
config.vm.define "datacoop" do |datacoop| config.vm.define "datacoop" do |datacoop|
datacoop.vm.box = "ubuntu/focal64" datacoop.vm.box = "ubuntu/focal64"
datacoop.vm.hostname = "datacoop" datacoop.vm.hostname = "datacoop"
@ -13,6 +17,14 @@ Vagrant.configure(2) do |config|
ansible.playbook = "playbook.yml" ansible.playbook = "playbook.yml"
ansible.ask_vault_pass = true ansible.ask_vault_pass = true
ansible.verbose = "v" ansible.verbose = "v"
# If we are running the provision command, then we override the ansible_port
if ARGV[0] == "provision"
ansible.host_vars = {
"datacoop" => {
"ansible_port" => PORT
}
}
end
end end
end end
end end

View file

@ -1,12 +1,15 @@
--- ---
- hosts: all - hosts: all
gather_facts: false gather_facts: true
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' }}"
letsencrypt_enabled: "{{ not vagrant }}"
services: services:
- nginx-proxy - nginx-proxy
- postfix - postfix
@ -33,19 +36,9 @@
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

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

View file

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

View file

@ -1,10 +1,16 @@
--- ---
- 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: not vagrant 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
tags: [install-base-packages] tags: [install-base-packages]
- import_tasks: users.yml - import_tasks: users.yml
tags: [setup-users] tags: [setup-users]