I looked over this list and i didn't find any answer on how to create a new network interface like you usually do with `ifconfig'. What i want to achieve is create an interface for every string item in a variable list, but before that i want to delete all interfaces excluding the one that ansible-playbook is using for deploying a play. Does any of you have an idea how to approach such task ?
Asked
Active
Viewed 2,109 times
-1
-
why a downvote ? pointout problems with question and i will try to fix it – Sackhorn Nov 17 '16 at 16:29
1 Answers
1
The NMCLI module is probably your best bet among the official modules.
http://docs.ansible.com/ansible/nmcli_module.html
You're going to want to do something like:
- Enumerate all interfaces into list (using either Ansible variables or parsing ifconfig output)
- Identify the one Ansible is connected over
- Exclude Ansible interface from list (using Jinja2 filters probably)
- Use NMCLI to remove all interfaces in filtered list.
- Use NMCLI to add all interfaces in separate list.

Wraezor Sharp
- 396
- 1
- 4
- 8
-
I would question the rationale of doing what you propose. Are you sure you want to remove interfaces every time you run the playbook? It seems counter-productive to Ansible's philosophy of idempotency. – Wraezor Sharp Nov 17 '16 at 17:34
-
i'm running a proxy server with changing pool of ip addresses so i want occasionally to be able to change all the interfaces i use with ansible assistance. – Sackhorn Nov 17 '16 at 20:08