aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/setup-network/tasks
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2015-09-19 16:26:40 +0800
committercarey.xu <carey.xuhan@huawei.com>2015-09-22 00:13:23 +0800
commit6bd52b2de366a9c20e6c93ae7fef80f711dc6e7b (patch)
treeaa3d9468200dc767aa6934801d24eb186cf48f25 /deploy/adapters/ansible/roles/setup-network/tasks
parent9ecbb2e352f22edec687ece5976c1015be643da3 (diff)
network config persistence
JIRA: COMPASS-62 Change-Id: I0774ac3b77ecc7ebfe8b4cd2236c36c3a3099f1d Signed-off-by: carey.xu <carey.xuhan@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/setup-network/tasks')
-rw-r--r--deploy/adapters/ansible/roles/setup-network/tasks/main.yml54
1 files changed, 28 insertions, 26 deletions
diff --git a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
index 8df1ac3a..689e6e3d 100644
--- a/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/setup-network/tasks/main.yml
@@ -14,30 +14,32 @@
with_items: "{{ network_cfg['provider_net_mappings'] }}"
when: 'item["type"] == "ovs"'
-- name: setup sys intf
- shell: ip link del {{ item.key }}; \
- ip link add link {{ item.value["interface"] }} name {{ item.key }} type vlan id {{ item.value["vlan_tag"] }}; \
- ip link set {{ item.value["interface"] }} up
- when: '"vlan_tag" in item.value and item.value["type"] == "vlan"'
- with_dict: "{{ sys_intf_mappings }}"
-
-
-- name: set sys intf ip
- shell: ip addr del {{ item.value["ip"] }}/{{ item.value["netmask"] }} dev {{ item.value["alias"] }}; \
- ip addr add {{ item.value["ip"] }}/{{ item.value["netmask"] }} dev {{ item.value["alias"] }}; \
- ip link set {{ item.value["alias"] }} up
- with_dict: "{{ host_ip_settings }}"
-
-- name: set gateway
- shell: ip route del default; \
- ip route add default via {{ item.value["gw"] }} dev {{ item.key }}
- when: '"gw" in item.value'
- with_dict: "{{ 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'
+- name: ensure script dir exist
+ shell: mkdir -p /opt/setup_networks
+
+- name: copy scripts
+ copy: src={{ item }} dest=/opt/setup_networks
+ with_items:
+ - setup_networks/log.py
+ - setup_networks/setup_networks.py
+
+- name: copy boot scripts
+ copy: src={{ item }} dest=/etc/init.d mode=0755
+ with_items:
+ - setup_networks/net_init
+
+- name: copy config files
+ template: src=network.cfg dest=/opt/setup_networks
+
+- name: make sure python lib exist
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+ with_items:
+ - python-yaml
+ - python-netaddr
+
+- name: run scripts
+ shell: python /opt/setup_networks/setup_networks.py
+
+- name: add to boot scripts
+ shell: update-rc.d net_init defaults 0 6
when: ansible_os_family == "Debian"