diff options
author | your name <email@163.com> | 2015-09-09 03:26:11 -0400 |
---|---|---|
committer | your name <email@163.com> | 2015-09-09 03:26:11 -0400 |
commit | 72039e915d1fc960bd0d7fccd910ea282d61bee7 (patch) | |
tree | 60452129b1b9f3c3419b4a29a038f5f0cbade5f7 /deploy/adapters/ansible/roles/setup-network/tasks | |
parent | cf87d3067a63cb8be315a3addfd9c27d86be3b5a (diff) |
Compass Netconfig optimization
Change-Id: Icbcfc7d794623436f22be5f6763b212a25d4fac7
JIRA: COMPASS-30
Diffstat (limited to 'deploy/adapters/ansible/roles/setup-network/tasks')
-rw-r--r-- | deploy/adapters/ansible/roles/setup-network/tasks/main.yml | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml new file mode 100644 index 00000000..94816044 --- /dev/null +++ b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml @@ -0,0 +1,43 @@ +--- +- name: add ovs bridge + openvswitch_bridge: bridge={{ item["name"] }} state=present + with_items: "{{ network_cfg['provider_net_mappings'] }}" + when: 'item["type"] == "ovs"' + +- name: add ovs uplink + openvswitch_port: bridge={{ item["name"] }} port={{ item["interface"] }} state=present + with_items: "{{ network_cfg['provider_net_mappings'] }}" + when: 'item["type"] == "ovs"' + +- name: add ovs uplink + shell: ip link set {{ item["interface"] }} up + with_items: "{{ network_cfg['provider_net_mappings'] }}" + when: 'item["type"] == "ovs"' + +- name: setup sys intf + shell: ip link del {{ item["name"] }}; \ + ip link add link {{ item["interface"] }} name {{ item["name"] }} type vlan id {{ item["vlan_tag"] }}; \ + ip link set {{ item["interface"] }} up + when: '"vlan_tag" in item' + with_items: "{{ network_cfg['sys_intf_mappings'] }}" + + +- name: set sys intf ip + shell: ip addr del {{ item["ip"] }}/{{ item["netmask"] }} dev {{ item["alias"] }}; \ + ip addr add {{ item["ip"] }}/{{ item["netmask"] }} dev {{ item["alias"] }}; \ + ip link set {{ item["alias"] }} up + with_items: "{{ host_ip_settings }}" + +- name: set gateway + shell: ip route del default; \ + ip route add default via {{ item["gw"] }} dev {{ item["alias"] }} + when: '"gw" in item' + with_items: "{{ host_ip_settings }}" + +- name: copy net config + template: src=my_configs.debian dest=/etc/network/interfaces.d/my_configs.cfg + when: ansible_os_family == "Debian" + +- name: source net config + lineinfile: dest=/etc/network/interfaces line='source /etc/network/interfaces.d/my_configs.cfg' + when: ansible_os_family == "Debian" |