Managed to resolve this myself with the following playbook

cat network-ip-config.yml
---
- hosts: all
  remote_user: root

  tasks:
  - name: Create IP Address list
    set_fact:
      addr_var1: "{{ guest_custom_ip + '/24' }}"
      addr_var2: "{{ virtual_alias_ip.split(', ')[0] + '/24' }}"
      addr_var3: "{{ virtual_alias_ip.split(', ')[1] + '/24' }}"
      addr_var4: "{{ virtual_alias_ip.split(', ')[2] + '/24' }}"

  - debug:
      var: addr_var1

  - debug:
      var: addr_var2

  - debug:
      var: addr_var3

  - debug:
      var: addr_var4


  - name: Pass variables to role
    include_role:
      name: linux-system-roles.network
    vars:
      network_provider: nm
      network_connections:
      - name: ens192
        type: ethernet
        interface_name: ens192
        autoconnect: yes
        ip:
          address:
          - "{{ addr_var1 }}"
          - "{{ addr_var2 }}"
          - "{{ addr_var3 }}"
          - "{{ addr_var4 }}"
          auto6: no
          dns:
          - X.X.X.X
          - 1.1.1.1
          dns_search:
          - example.co.uk

  - name: Unconditionally reboot the machine with all defaults
    reboot:


On Tuesday, June 30, 2020 at 11:57:43 AM UTC+1 Paul Robinson wrote:

> Firstly just to say I'm new to ansible and learning as I go along.
>
> I have configure a playbook that clones 3 virtual machines using the 
> following inventory file which has a few custom variables added for my needs
>
> ansible-playbook -i vms-to-deploy deploy_sap_vm.yml
>
> vms-to-deploy
> [netweaver]
> prcsapnwd01 deploy_vsphere_datastore='datastore2' 
> guest_custom_ip='10.0.14.20' sap_sid='NWD' 
> virtual_alias_ip='10.0.14.21,10.0.14.22,10.0.14.23'
> prcsapnwq01 deploy_vsphere_datastore='datastore2' 
> guest_custom_ip='10.0.14.30' sap_sid='NWQ' 
> virtual_alias_ip='10.0.14.31,10.0.14.32,10.0.14.33'
> prcsapnwp01 deploy_vsphere_datastore='datastore2' 
> guest_custom_ip='10.0.14.40' sap_sid='NWP' 
> virtual_alias_ip='10.0.14.41,10.0.14.32,10.0.14.43'
>
> I have successfully managed to clone the vm's using vmware_guest role 
> which then customizes the virtual machines and assigns the guest_custom_ip 
> to be the ip of the physical interface eth0
>
> The next task I want to perform is to add additional ip addresses to that 
> adapter eth0 so for example in the case of host prcsapnwd01 eth0 has
>
> eth0:
> 10.0.14.20 (Phsyical Host)
> 10.0.14.21 (Virtual Alias IP)
> 10.0.14.22 (Virtual Alias IP)
> 10.0.14.23 (Virtual Alias IP)
>
> The linux-system-roles.network looks like it can do the job for me.
>
> I am just not sure how i go about reading the additional ip addresses from 
> my inventory file and passing them to the task variables.
>
> Any help would be appreciated. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/30dff693-7a2f-41ec-9736-f142884fbfdfn%40googlegroups.com.

Reply via email to