Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #variable file
- interfaces_ipv4:
- - name: ens34
- bootproto: static
- ipaddress: 10.0.0.100
- netmask: 255.0.0.0
- onboot: yes
- #template.j2 file
- BOOTPROTO={{item.bootproto}}
- {% if item.bootproto == static %}
- IPADDR={{item.ipaddress}}
- {% endif %}
- NETMASK={{item.netmask}}
- {% if item.gateway is defined %}
- GATEWAY={{item.gateway}}
- {% endif %}
- #playbook
- template:
- src=/playbooks/roles/template/tasks/template.j2
- dest=/etc/sysconfig/network-scripts/ifcfg-{{item.name}}
- with_items:
- - "{{ interfaces_ipv4 }}"
- tags:
- - network_config
- #Error when running
- fatal: [192.168.211.142] => {'msg': "One or more undefined variables: 'static' is undefined", 'failed': True}
- fatal: [192.168.211.142] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': "One or more undefined variables: 'static' is undefined", 'failed': True}]}
- FATAL: all hosts have already failed -- aborting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement