Reputation: 7028
I had to do NIC bonding using Ansible. I have 4 NIC on the machine & tried this play, which I have taken from here
---
#ansible-playbook -i hosts/groups.dat -l vertica07.abc.com vertica-network.yml -e '{ "bond1_ip" : "10.253.1.7" }' -u root -k
- hosts: vertica
gather_facts: true
sudo: yes
vars:
- bond1_ip: "{{ bond1_ip }}"
- bond1_gw: "x.x.x.x"
#bond vars
- nmcli_bond:
- {conn_name: 'bond0', ip4: "{{ ansible_default_ipv4.address }}", gw4: "{{ ansible_default_ipv4.gateway }}", mode: 'active-backup'}
- {conn_name: 'bond1', ip4: "{{ bond1_ip }}", gw4: 'bond1_gw', mode: 'active-backup'}
- nmcli_bond_slave:
- {conn_name: 'p1p1', ifname: 'p1p1', master: 'bond0'}
- {conn_name: 'p1p2', ifname: 'p1p2', master: 'bond0'}
- {conn_name: 'p2p1', ifname: 'p2p1', master: 'bond1'}
- {conn_name: 'p2p2', ifname: 'p2p2', master: 'bond1'}
#ethernet vars
- nmcli_ethernet:
- {conn_name: 'p1p1', ifname: 'p1p1', ip4: "{{ ansible_default_ipv4.address }}", gw4: "{{ ansible_default_ipv4.gateway }}"}
- {conn_name: 'p1p2', ifname: 'p1p2', ip4: "{{ ansible_default_ipv4.address }}", gw4: "{{ ansible_default_ipv4.gateway }}"}
- {conn_name: 'p2p1', ifname: 'p2p1', ip4: "{{ bond1_ip }}", gw4: "{{ bond1_gw }}"}
- {conn_name: 'p2p2', ifname: 'p2p2', ip4: "{{ bond1_ip }}", gw4: "{{ bond1_gw }}"}
tasks:
- name: install needed network manager libs
yum: name={{ item }} state=installed
with_items:
- NetworkManager-glib
- libnm-qt-devel.x86_64
- nm-connection-editor.x86_64
- libsemanage-python
- policycoreutils-python
- name: try nmcli add bond - conn_name only & ip4 gw4 mode
nmcli: type=bond conn_name={{item.conn_name}} ip4={{item.ip4}} gw4={{item.gw4}} mode={{item.mode}} state=present
with_items:
- "{{nmcli_bond}}"
- name: try nmcli add bond-slave
nmcli: type=bond-slave conn_name={{item.conn_name}} ifname={{item.ifname}} master={{item.master}} state=present
with_items:
- "{{nmcli_bond_slave}}"
But its failing on
TASK [try nmcli add bond - conn_name only & ip4 gw4 mode] **********************
failed: [vertica07.abc.com] => (item={u'conn_name': u'bond0', u'mode': u'active-backup', u'ip4': u'10.100.1.7', u'gw4': u'bond0_gw'}) => {"failed": true, "item": {"conn_name": "bond0", "gw4": "bond0_gw", "ip4": "10.100.1.7", "mode": "active-backup"}, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1459368691.93-148688989216143/nmcli\", line 385, in <module>\r\n from gi.repository import NetworkManager, NMClient\r\nImportError: No module named gi.repository\r\n", "msg": "MODULE FAILURE", "parsed": false}
failed: [vertica07.abc.com] => (item={u'conn_name': u'bond1', u'mode': u'active-backup', u'ip4': u'10.253.1.7', u'gw4': u'bond1_gw'}) => {"failed": true, "item": {"conn_name": "bond1", "gw4": "bond1_gw", "ip4": "10.253.1.7", "mode": "active-backup"}, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1459368692.4-174709839763552/nmcli\", line 385, in <module>\r\n from gi.repository import NetworkManager, NMClient\r\nImportError: No module named gi.repository\r\n", "msg": "MODULE FAILURE", "parsed": false}
I am on Ansible 2.0.1 and doing Network bonding on Centos 6.3. At present I am running this just on single host.
Whats I am missing here ?
Thanks
Upvotes: 0
Views: 5434
Reputation: 1
Had similar error in RHEL 7 and its fixed by installing PyGObject2 like Raul Mentions above
[root@node1 ~]# rpm -qa --last | head pygobject2-2.28.6-11.el7.x86_64
Upvotes: 0
Reputation: 51
Try using:
- libnm-gtk-devel.x86_64
Instead of:
- libnm-qt-devel.x86_64
I'm currently using ansible 2.0.1 in my CentOS 7 server.
Upvotes: 1
Reputation: 1136
Try installing Python-gobject in CentOs try with:
yum install NetworkManager-glib
yum install pygobject2
https://live.gnome.org/PyGObject
The module needs that pyhton dependence.
Upvotes: 0