Keep ansible "clean" and do ssh port magic in Vagrantfile.

This commit is contained in:
Víðir Valberg Guðmundsson 2022-11-17 08:53:45 +01:00
parent 57ca1e9233
commit 9a5d780f2b
7 changed files with 24 additions and 22 deletions

16
Vagrantfile vendored
View File

@ -1,7 +1,11 @@
Vagrant.require_version ">= 1.7.0"
PORT = 19022
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|
datacoop.vm.box = "ubuntu/focal64"
datacoop.vm.hostname = "datacoop"
@ -13,6 +17,14 @@ Vagrant.configure(2) do |config|
ansible.playbook = "playbook.yml"
ansible.ask_vault_pass = true
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

View File

@ -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' }}"
letsencrypt_enabled: "{{ not vagrant }}"
services:
- nginx-proxy
- postfix
@ -33,19 +36,9 @@
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

@ -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
tags: [setup-dell-apt-repo]
when: not vagrant
- import_tasks: upgrade.yml
tags: [do-full-system-upgrade]
- import_tasks: base.yml
tags: [install-base-packages]
- import_tasks: users.yml
tags: [setup-users]