diff --git a/playbooks/create_droplet.yml b/playbooks/create_droplet.yml index fc7ece1..c2feb30 100644 --- a/playbooks/create_droplet.yml +++ b/playbooks/create_droplet.yml @@ -5,7 +5,7 @@ vars: mpdf: - 'nyc3-mpdf' - number: 5 + count: 5 mpdb: - 'nyc3-mpdb' tasks: @@ -24,7 +24,7 @@ - 'ansible' - 'mpdf' register: created_droplets - with_sequence: count="{{ number }}" + loop: "{{ range(1,count+1)|list }}" - name: create backend droplets digital_ocean_droplet: @@ -32,7 +32,7 @@ region: nyc3 image: debian-11-x64 wait_timeout: 100 - name: "mpdf{{item }}" + name: "mpdf{{ item }}" size_id: s-1vcpu-1gb state: present oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" @@ -41,5 +41,5 @@ - 'ansible' - 'mpdb' register: created_droplets - with_sequence: count="{{ number }}" + loop: "{{ range(1,count+1)|list }}" diff --git a/playbooks/delete_droplet.yml b/playbooks/delete_droplet.yml index c669745..c7d73f8 100644 --- a/playbooks/delete_droplet.yml +++ b/playbooks/delete_droplet.yml @@ -5,9 +5,7 @@ vars: mpdf: - 'nyc3-mpdf' - number: - - '1' - - '2' + count: 5 mpdb: - 'nyc3-mpdb' tasks: @@ -17,25 +15,31 @@ region: nyc3 image: debian-11-x64 wait_timeout: 100 - name: "{{ item.0 }}{{item.1 }}" + name: "mpdb{{ item }}" size_id: s-1vcpu-1gb state: absent oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" ssh_keys: [ '94:5e:bc:d4:fe:5a:b0:74:7f:06:fc:4e:3d:f7:3e:ea' ] # <---- put your numeric ssh key in here + tags: + - 'ansible' + - 'mpdf' register: deleted_droplets - loop: "{{ mpdf | product(number) }}" - - - name: delete backend droplets + loop: "{{ range(1,count+1)|list }}" + + - name: delete backend droplets digital_ocean_droplet: unique_name: yes region: nyc3 image: debian-11-x64 wait_timeout: 100 - name: "{{ item.0 }}{{item.1 }}" + name: "mpdf{{ item }}" size_id: s-1vcpu-1gb state: absent oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" ssh_keys: [ '94:5e:bc:d4:fe:5a:b0:74:7f:06:fc:4e:3d:f7:3e:ea' ] # <---- put your numeric ssh key in here + tags: + - 'ansible' + - 'mpdb' register: deleted_droplets - loop: "{{ mpdb | product(number) }}" - + loop: "{{ range(1,count+1)|list }}" +