From 8bfb3a1361d8ee31b51ab65c85bd63029035f351 Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 25 Aug 2023 10:13:29 +0200 Subject: [PATCH] create vagrant file and adapt process --- .gitignore | 3 ++ Vagrantfile | 81 +++++++++++++++++++++++++++++++++ ansible/makefile | 13 ++---- ansible/playbooks/bootstrap.yml | 1 + makefile | 5 +- 5 files changed, 93 insertions(+), 10 deletions(-) create mode 100644 Vagrantfile diff --git a/.gitignore b/.gitignore index 7477ea7..3797d36 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ override.tf.json .terraformrc terraform.rc site + + +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..69dc259 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,81 @@ +Vagrant.configure('2') do |config| + if Vagrant.has_plugin?('vagrant-cachier') + config.cache.scope = 'machine' + end + config.vm.define "oscar-dev" do |c| + # Box definition + c.vm.box = "archlinux/archlinux" + # Config options + c.vm.synced_folder ".", "/vagrant", disabled: true + c.ssh.insert_key = true + c.vm.hostname = "oscar-dev" + # Network + + # instance_raw_config_args + # Provider + c.vm.provider "libvirt" do |libvirt, override| + + libvirt.memory = 1024 + libvirt.cpus = 2 + end + end + + config.vm.define "merlin-dev" do |c| + # Box definition + c.vm.box = "generic/rocky9" + # Config options + c.vm.synced_folder ".", "/vagrant", disabled: true + c.ssh.insert_key = true + c.vm.hostname = "merlin-dev" + # Network + # instance_raw_config_args + # Provider + c.vm.provider "libvirt" do |libvirt, override| + + libvirt.memory = 1024 + libvirt.cpus = 2 + + end + end + + config.vm.define "gerard-dev" do |c| + # Box definition + c.vm.box = "debian/bookworm64" + # Config options + + c.vm.synced_folder ".", "/vagrant", disabled: true + c.ssh.insert_key = true + c.vm.hostname = "gerard-dev" + # Network + # instance_raw_config_args + # Provider + c.vm.provider "libvirt" do |libvirt, override| + libvirt.memory = 1024 + libvirt.cpus = 2 + end + end + + config.vm.define "nas-dev" do |c| + # Box definition + c.vm.box = "archlinux/archlinux" + # Config options + c.vm.synced_folder ".", "/vagrant", disabled: true + c.ssh.insert_key = true + c.vm.hostname = "nas-dev" + # Network + # instance_raw_config_args + # Provider + c.vm.provider "libvirt" do |libvirt, override| + + libvirt.memory = 1024 + libvirt.cpus = 2 + end + + c.vm.provision "ansible" do |bootstrap| + bootstrap.playbook= "ansible/playbooks/bootstrap.yml" + bootstrap.galaxy_roles_path= "ansible/roles" + bootstrap.limit="all" + { ansible_python_interpreter:"/usr/bin/python3" } + end + end +end diff --git a/ansible/makefile b/ansible/makefile index ce111e0..28848fd 100644 --- a/ansible/makefile +++ b/ansible/makefile @@ -2,15 +2,12 @@ requirements: ansible-galaxy install -g -r roles/requirements.yml -deploy_production: +deploy_production: generate-token ansible-playbook site.yml -i production -u ansible +deploy_staging: generate-token + ansible-playbook site.yml -i staging -u ansible + generate-token: - @echo export VAULT_TOKEN=`vault token create -policy=ansible -field="token" -period 6h` + export VAULT_TOKEN=`vault token create -policy=ansible -field="token" -period 6h` - -create-dev: requirements - PY_COLORS=1 molecule converge - -destroy-dev: - PY_COLORS=1 molecule destroy diff --git a/ansible/playbooks/bootstrap.yml b/ansible/playbooks/bootstrap.yml index 6df5efb..887738d 100644 --- a/ansible/playbooks/bootstrap.yml +++ b/ansible/playbooks/bootstrap.yml @@ -1,4 +1,5 @@ --- - hosts: all + become: true roles: - ansible_bootstrap diff --git a/makefile b/makefile index b36f891..4ba9cf0 100644 --- a/makefile +++ b/makefile @@ -11,10 +11,11 @@ vault-dev: fi create-dev: - make -C ansible create-dev + vagrant up + make -C ansible deploy_staging destroy-dev: - make -C ansible destroy-dev + vagrant destroy serve: mkdocs serve