Help creating an ansible playbook

39 views
Skip to first unread message

andrew thornton

unread,
Apr 7, 2014, 4:10:32 PM4/7/14
to ansible...@googlegroups.com
Hello everyone,

I am new to ansible but I am really enjoying it. I am trying to create a playbook to spin up new droplets (servers) at DigitalOcean. I have the following playbook put together and I need a little help.

My first task "Create new staging droplets" works very well, but I need to create a DNS record for each server that is created and I am not sure how to go about this. I am starting to think that using a "with_items" dictionary isn't the best way to go about this. In the end, I just need to make a call with the digital_ocean_domain module for each server with its newly assigned IP address.

Can someone help steer me in the right direction?

---
- hosts: 127.0.0.1
  connection: local
  gather_facts: false

  tasks:
    - name: "Create new staging droplets"
      digital_ocean: >
          state=present
          command=droplet
          name={{ item.hostname }}
          client_id=XXXXXXXXXXXXXXXXXXXXXXXXX
          api_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
          size_id={{ item.size }}
          region_id=4
          image_id=1505447
          private_networking=true
          wait_timeout=500
          unique_name=yes
          ssh_key_ids=XXXXXXX
      with_items:
        - { hostname: 'stage-web01.testsite.com', size: '66'}
        - { hostname: 'stage-app01.testsite.com', size: '66'}
        - { hostname: 'stage-db01.testsite.com', size: '66'}
      register: droplet

    - name: "Create DNS Entries"
      digital_ocean_domain: >
        state=present
        client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        api_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
        name={{ droplet.name }}.testsite.com
        ip={{ droplet.ip_address }}


I appreciate it,

Andrew
Reply all
Reply to author
Forward
0 new messages