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 PORT = 19022
Vagrant.configure(2) do |config| def provisioned?(vm="default", provider="virtualbox")
config.vm.network :forwarded_port, guest: PORT, host: PORT, id: "new_ssh" 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 Vagrant.configure(2) do |config|
if ARGV[0] == "ssh" config.vm.network :private_network, ip: "192.168.56.10"
config.ssh.guest_port = PORT 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 end
config.vm.define "datacoop" do |datacoop| config.vm.provision :ansible do |ansible|
datacoop.vm.box = "ubuntu/focal64" ansible.compatibility_mode = "2.0"
datacoop.vm.hostname = "datacoop" 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| # If the VM is already provisioned, we need to use the new port
v.memory = 4096 if provisioned?
end config.ssh.guest_port = PORT
ansible.extra_vars = {
datacoop.vm.provision "ansible" do |ansible| ansible_port: PORT
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
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 }}"