diff --git a/playbooks/create_droplet.yml b/playbooks/create_droplet.yml index c33a78d..57fd5f5 100644 --- a/playbooks/create_droplet.yml +++ b/playbooks/create_droplet.yml @@ -1,26 +1,45 @@ --- -- hosts: localhost +- hosts: all connection: local gather_facts: false - + vars: + mpdf: + - 'nyc3-mpdf' + number: + - '1' + - '2' + mpdb: + - 'nyc3-mpdb' tasks: - - name: create two droplets + - name: create frontend droplets digital_ocean_droplet: unique_name: yes - region: ams3 - image: ubuntu-18-10-x64 + region: nyc3 + image: debian-11-x64 wait_timeout: 100 - name: "{{ item }}" + name: "{{ item.0 }}{{item.1 }}" size_id: s-1vcpu-1gb state: present - ssh_keys: [ '1' ] # <---- put your numeric ssh key in here + 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 register: created_droplets - with_items: - - tmp-droplet-1 - - tmp-droplet-2 - - - name: add to dynamic inventory - add_host: - name: "{{ item.data.ip_address }}" - group: do - with_items: "{{ created_droplets.results }}" + loop: "{{ mpdf | product(number) }}" + + - name: create backend droplets + digital_ocean_droplet: + unique_name: yes + region: nyc3 + image: debian-11-x64 + wait_timeout: 100 + name: "{{ item.0 }}{{item.1 }}" + size_id: s-1vcpu-1gb + state: present + 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 + register: created_droplets + loop: "{{ mpdb | product(number) }}" + - name: Install mpd on hosts + apt: + name: mpd + state: present +