Some improvements

- Always use the new port if the VM is already provisioned
- We're not using a multi-VM setup, so no need to define VM "datacoop"
- Increase minimum required Vagrant version
- Add static IP for hopefully implementing some sort of DNS in the
  future
- Hardcode registry domain to use the real registry in Vagrant
This commit is contained in:
Sam A. 2022-11-18 23:15:56 +01:00
parent d48e684647
commit a67d82ad88
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA
2 changed files with 28 additions and 29 deletions

55
Vagrantfile vendored
View file

@ -1,37 +1,36 @@
Vagrant.require_version ">= 1.7.0"
Vagrant.require_version ">= 2.0.0"
PORT = 19022
Vagrant.configure(2) do |config|
config.vm.network :forwarded_port, guest: PORT, host: PORT, id: "new_ssh"
def provisioned?(vm="default", provider="virtualbox")
File.exist?(".vagrant/machines/#{vm}/#{provider}/action_provision")
end
# 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
Vagrant.configure(2) do |config|
config.vm.network :private_network, ip: "192.168.56.10"
config.vm.network :forwarded_port, guest: PORT, host: PORT
config.vm.box = "ubuntu/focal64"
config.vm.hostname = "datacoop"
config.vm.provider :virtualbox do |v|
v.memory = 4096
end
config.vm.define "datacoop" do |datacoop|
datacoop.vm.box = "ubuntu/focal64"
datacoop.vm.hostname = "datacoop"
config.vm.provision :ansible do |ansible|
ansible.compatibility_mode = "2.0"
ansible.playbook = "playbook.yml"
ansible.ask_vault_pass = true
ansible.verbose = "v"
ansible.extra_vars = {
base_domain: "datacoop.devel"
}
datacoop.vm.provider "virtualbox" do |v|
v.memory = 4096
end
datacoop.vm.provision "ansible" do |ansible|
ansible.compatibility_mode = "2.0"
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
# If the VM is already provisioned, we need to use the new port
if provisioned?
config.ssh.guest_port = PORT
ansible.extra_vars = {
ansible_port: PORT
}
end
end
end

View file

@ -30,6 +30,6 @@
- name: log in to registry
docker_login:
registry: "{{ docker_registry.domain }}"
registry: "docker.data.coop"
username: "docker"
password: "{{ docker_password }}"