From 4d77b60ce4fe78e4489cd62bd5aa9d218a26e906 Mon Sep 17 00:00:00 2001 From: Erin Sims Date: Sat, 17 Sep 2022 19:09:22 -0400 Subject: [PATCH] installed the do ansible inventory command into the delete and create ansible script, since the actualy inventory plugin does not fucking work --- playbooks/create_droplet.yml | 2 ++ playbooks/delete_droplet.yml | 4 +++- playbooks/digitalocean.yaml | 26 -------------------------- playbooks/do_hosts.yml | 26 -------------------------- 4 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 playbooks/digitalocean.yaml delete mode 100644 playbooks/do_hosts.yml diff --git a/playbooks/create_droplet.yml b/playbooks/create_droplet.yml index f324927..64bae10 100644 --- a/playbooks/create_droplet.yml +++ b/playbooks/create_droplet.yml @@ -102,6 +102,8 @@ destinations: addresses: ["0.0.0.0/0", "::/0"] tags: ["mpdb"] + - name: update inventory + ansible.builtin.command: "do-ansible-inventory --access-token {{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }} > /etc/ansible/hosts" - name: mpdb ansible.builtin.import_playbook: mpdb.yaml - name: mpdf diff --git a/playbooks/delete_droplet.yml b/playbooks/delete_droplet.yml index d4b2fb3..d487625 100644 --- a/playbooks/delete_droplet.yml +++ b/playbooks/delete_droplet.yml @@ -42,4 +42,6 @@ - 'mpdb' register: deleted_droplets loop: "{{ range(1,count|int + 1) }}" - + - name: update inventory + ansible.builtin.command: "do-ansible-inventory --access-token {{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }} > /etc/ansible/hosts" + diff --git a/playbooks/digitalocean.yaml b/playbooks/digitalocean.yaml deleted file mode 100644 index 7ec0dc9..0000000 --- a/playbooks/digitalocean.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Using keyed groups and compose for hostvars -plugin: community.digitalocean.digitalocean -api_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" -attributes: - - id - - name - - memory - - vcpus - - disk - - size - - image - - networks - - volume_ids - - tags - - region -keyed_groups: - - key: do_tags | lower - prefix: '' - separator: '' -compose: - ansible_host: do_networks.v4 | selectattr('type','eq','public') - | map(attribute='ip_address') | first - class: do_size.description | lower - distro: do_image.distribution | lower -filters: - - '"ansible" in do_tags' diff --git a/playbooks/do_hosts.yml b/playbooks/do_hosts.yml deleted file mode 100644 index 7ec0dc9..0000000 --- a/playbooks/do_hosts.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Using keyed groups and compose for hostvars -plugin: community.digitalocean.digitalocean -api_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" -attributes: - - id - - name - - memory - - vcpus - - disk - - size - - image - - networks - - volume_ids - - tags - - region -keyed_groups: - - key: do_tags | lower - prefix: '' - separator: '' -compose: - ansible_host: do_networks.v4 | selectattr('type','eq','public') - | map(attribute='ip_address') | first - class: do_size.description | lower - distro: do_image.distribution | lower -filters: - - '"ansible" in do_tags'