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

39
Vagrantfile vendored
View file

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

View file

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