diff --git a/.gitignore b/.gitignore index 31afee7..7cc3fb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea ansible.cfg -Vault/ \ No newline at end of file +Vault/ +.sudo_pass \ No newline at end of file diff --git a/Inventories/QA b/Inventories/QA index 5c7451c..20adac9 100644 --- a/Inventories/QA +++ b/Inventories/QA @@ -1,2 +1,2 @@ -[ubuntu-lxd] -mps.org.uy \ No newline at end of file +[ubuntu_lxd] +mps.org.uy ansible_ssh_port=8032 \ No newline at end of file diff --git a/Playbooks/01-UBUNTU-LXD.yml b/Playbooks/01-UBUNTU-LXD.yml index b2c5e00..2ea0564 100644 --- a/Playbooks/01-UBUNTU-LXD.yml +++ b/Playbooks/01-UBUNTU-LXD.yml @@ -1,9 +1,10 @@ -- hosts: ubuntu-lxd +# ansible-playbook Playbooks/01-UBUNTU-LXD.yml -i Inventories/QA --ask-become-pass + +- hosts: ubuntu_lxd vars: sudoers: - - renzo - lxd - gather_facts: false + gather_facts: true tasks: #- ansible.builtin.include_role: name=new_sudoers_user - name: Install packages @@ -14,6 +15,17 @@ - "ansible" - "zfsutils-linux" - - ansible.builtin.include_role: name=init_lxd - #vars: lxd_init_yaml_config_path="myPath" + - ansible.builtin.include_role: + name: init_lxd + #vars: + # - lxd_init_template_config_path="/path/to/my/template" + + +## Rollback +- hosts: ubuntu_lxd + tags: + - rollback + tasks: + - shell: "snap remove --purge lxd" + become: true diff --git a/Playbooks/roles/init_lxd/defaults/main.yml b/Playbooks/roles/init_lxd/defaults/main.yml index cdc84fc..353c223 100644 --- a/Playbooks/roles/init_lxd/defaults/main.yml +++ b/Playbooks/roles/init_lxd/defaults/main.yml @@ -1,3 +1,4 @@ --- # defaults file for roles/init_lxd -lxd_init_yaml_config_path: "files/default_config.yml" \ No newline at end of file +lxd_init_template_config_path: "templates/default_config.yml.j2" +lxd_init_template_processed_path: "/tmp/default_config.yml" \ No newline at end of file diff --git a/Playbooks/roles/init_lxd/tasks/main.yml b/Playbooks/roles/init_lxd/tasks/main.yml index 220b80c..3c0a36e 100644 --- a/Playbooks/roles/init_lxd/tasks/main.yml +++ b/Playbooks/roles/init_lxd/tasks/main.yml @@ -1,16 +1,33 @@ --- # tasks file for roles/init_lxd - name: Install lxd + become: true ansible.builtin.snap: name: lxd classic: yes +- ansible.builtin.debug: + var: + verbosity: 1 + +- delegate_to: localhost + delegate_facts: true + ansible.builtin.copy: + content: "{{hostvars[inventory_hostname]}}" + dest: ./test.json + +- delegate_to: localhost + delegate_facts: true + ansible.builtin.template: + src: "{{lxd_init_template_config_path}}" + dest: "{{lxd_init_template_processed_path}}" + ## tira el lxd init con los parametros -- name: "Preseeding LXD Init with: {{lxd_init_yaml_config_path}}" +- name: "Preseeding LXD Init with template: {{lxd_init_template_config_path}}" become: true ansible.builtin.shell: | cat <