---
#TODO: remove this when the templating system is in place
- name: External network creation
  hosts: undercloud
  gather_facts: no
  become: yes
  become_user: "{{ installer.user.name }}"
  vars:
      first_controller: "{{ groups.controller | first }}"
  tasks:
      - name: get the default floating ip pool name from the controller
        shell: "grep -oP \"(?<=default_floating_pool=)(.*$)\" /etc/nova/nova.conf"
        register: pool_name
        delegate_to: first_controller
        become_user: root
        become: yes

      - name: create the external network
        shell: "source ~/overcloudrc; neutron net-create {{ pool_name.stdout_lines|last }} --router:external --provider:physical_network datacentre --provider:network_type flat"

        # TODO: move the hard coded value to a variable
      - name: create the external subnet
        shell: "source ~/overcloudrc; neutron subnet-create {{ pool_name.stdout_lines|last }} 10.0.0.1/24 --name external_subnet --enable-dhcp=False --allocation-pool start=10.0.0.210,end=10.0.0.250 --gateway 10.0.0.1"

---
#TODO: remove this when the templating system is in place
- name: External network creation
  hosts: undercloud
  gather_facts: no
  become: yes
  become_user: "{{ installer.user.name }}"
  vars:
      first_controller: "{{ groups.controller | first }}"
  tasks:
      - name: get the default floating ip pool name from the controller
        shell: "grep -oP \"(?<=default_floating_pool=)(.*$)\" /etc/nova/nova.conf"
        register: pool_name
        delegate_to: "{{ first_controller }}"
        become_user: root
        become: yes

      - name: create the external network
        shell: "source ~/overcloudrc; neutron net-create {{ pool_name.stdout_lines|last }} --router:external --provider:physical_network datacentre --provider:network_type flat"

        # TODO: move the hard coded value to a variable
      - name: create the external subnet
        shell: "source ~/overcloudrc; neutron subnet-create {{ pool_name.stdout_lines|last }} 10.0.0.1/24 --name external_subnet --enable-dhcp=False --allocation-pool start=10.0.0.210,end=10.0.0.250 --gateway 10.0.0.1"

Make sure the first_controller is variable not a string
Make sure the first_controller is variable not a string

Looks like the floating ip pool name was read from the
undercloud-0 instead of delegating to the specified node.

Also looks like the currently used ansible version ignores the
delegates-to parameter if it does not exists.

Using the "{{ var_name }}' style.

Change-Id: I44f02dbf8dd238c7b9efc34e612883043657bfd4
