Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #variable file
  2. interfaces_ipv4:
  3. - name: ens34
  4. bootproto: static
  5. ipaddress: 10.0.0.100
  6. netmask: 255.0.0.0
  7. onboot: yes
  8.  
  9. #template.j2 file
  10. BOOTPROTO={{item.bootproto}}
  11. {% if item.bootproto == static %}
  12. IPADDR={{item.ipaddress}}
  13. {% endif %}
  14. NETMASK={{item.netmask}}
  15. {% if item.gateway is defined %}
  16. GATEWAY={{item.gateway}}
  17. {% endif %}
  18.  
  19. #playbook
  20. template:
  21. src=/playbooks/roles/template/tasks/template.j2
  22. dest=/etc/sysconfig/network-scripts/ifcfg-{{item.name}}
  23. with_items:
  24. - "{{ interfaces_ipv4 }}"
  25. tags:
  26. - network_config
  27. #Error when running
  28. fatal: [192.168.211.142] => {'msg': "One or more undefined variables: 'static' is undefined", 'failed': True}
  29. 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}]}
  30.  
  31. FATAL: all hosts have already failed -- aborting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement