Browse Source

ranges for loops are working now too thanks to brainist

master
erin sims 2 years ago
parent
commit
f86d64c405
2 changed files with 18 additions and 14 deletions
  1. +4
    -4
      playbooks/create_droplet.yml
  2. +14
    -10
      playbooks/delete_droplet.yml

+ 4
- 4
playbooks/create_droplet.yml View File

@@ -5,7 +5,7 @@
vars: vars:
mpdf: mpdf:
- 'nyc3-mpdf' - 'nyc3-mpdf'
number: 5
count: 5
mpdb: mpdb:
- 'nyc3-mpdb' - 'nyc3-mpdb'
tasks: tasks:
@@ -24,7 +24,7 @@
- 'ansible' - 'ansible'
- 'mpdf' - 'mpdf'
register: created_droplets register: created_droplets
with_sequence: count="{{ number }}"
loop: "{{ range(1,count+1)|list }}"


- name: create backend droplets - name: create backend droplets
digital_ocean_droplet: digital_ocean_droplet:
@@ -32,7 +32,7 @@
region: nyc3 region: nyc3
image: debian-11-x64 image: debian-11-x64
wait_timeout: 100 wait_timeout: 100
name: "mpdf{{item }}"
name: "mpdf{{ item }}"
size_id: s-1vcpu-1gb size_id: s-1vcpu-1gb
state: present state: present
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
@@ -41,5 +41,5 @@
- 'ansible' - 'ansible'
- 'mpdb' - 'mpdb'
register: created_droplets register: created_droplets
with_sequence: count="{{ number }}"
loop: "{{ range(1,count+1)|list }}"

+ 14
- 10
playbooks/delete_droplet.yml View File

@@ -5,9 +5,7 @@
vars: vars:
mpdf: mpdf:
- 'nyc3-mpdf' - 'nyc3-mpdf'
number:
- '1'
- '2'
count: 5
mpdb: mpdb:
- 'nyc3-mpdb' - 'nyc3-mpdb'
tasks: tasks:
@@ -17,25 +15,31 @@
region: nyc3 region: nyc3
image: debian-11-x64 image: debian-11-x64
wait_timeout: 100 wait_timeout: 100
name: "{{ item.0 }}{{item.1 }}"
name: "mpdb{{ item }}"
size_id: s-1vcpu-1gb size_id: s-1vcpu-1gb
state: absent state: absent
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" 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 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 register: deleted_droplets
loop: "{{ mpdf | product(number) }}"
- name: delete backend droplets
loop: "{{ range(1,count+1)|list }}"
- name: delete backend droplets
digital_ocean_droplet: digital_ocean_droplet:
unique_name: yes unique_name: yes
region: nyc3 region: nyc3
image: debian-11-x64 image: debian-11-x64
wait_timeout: 100 wait_timeout: 100
name: "{{ item.0 }}{{item.1 }}"
name: "mpdf{{ item }}"
size_id: s-1vcpu-1gb size_id: s-1vcpu-1gb
state: absent state: absent
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}" 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 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 register: deleted_droplets
loop: "{{ mpdb | product(number) }}"
loop: "{{ range(1,count+1)|list }}"

Loading…
Cancel
Save