diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..14c8065 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +host_key_checking = False diff --git a/playbooks/create_droplet.yml b/playbooks/create_droplet.yml new file mode 100644 index 0000000..c33a78d --- /dev/null +++ b/playbooks/create_droplet.yml @@ -0,0 +1,26 @@ +--- +- hosts: localhost + connection: local + gather_facts: false + + tasks: + - name: create two droplets + digital_ocean_droplet: + unique_name: yes + region: ams3 + image: ubuntu-18-10-x64 + wait_timeout: 100 + name: "{{ item }}" + size_id: s-1vcpu-1gb + state: present + ssh_keys: [ '1' ] # <---- 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 }}" diff --git a/playbooks/index.html.j2 b/playbooks/index.html.j2 new file mode 100644 index 0000000..95b713a --- /dev/null +++ b/playbooks/index.html.j2 @@ -0,0 +1,3 @@ +

On a digital ocean droplet now

+ +

The ip address where we're at is: {{ ansible_default_ipv4.address }}

diff --git a/playbooks/nginx.yml b/playbooks/nginx.yml new file mode 100644 index 0000000..0100006 --- /dev/null +++ b/playbooks/nginx.yml @@ -0,0 +1,26 @@ +- hosts: do + remote_user: root + gather_facts: false + + vars: + ansible_python_interpreter: /usr/bin/python3 + + tasks: + - name: wait for port 22 to become available + wait_for: + host: "{{ inventory_hostname }}" + port: 22 + delegate_to: localhost + + - name: Gather Facts + setup: + + - name: install nginx + apt: + name: nginx + + - name: modify html file + template: + src: ./index.html.j2 + dest: /var/www/html/index.html +