aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-route.yml
blob: 0168728141454e0ddc486965c0c14d67a63ff71b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
#- hosts: all
#  sudo: yes
#  tasks:
- name: "delete existing route file"
#  sudo: True
  file:
    path: "/etc/network/if-up.d/routes"
    state: absent
  when: contrail_route

- name: "create route file"
#  sudo: True
  file:
    path: "/etc/network/if-up.d/routes"
    owner: "root"
    mode: 0755
    state: touch 
  when: contrail_route


- name: "add template"
#  sudo: True
  lineinfile:
    dest: "/etc/network/if-up.d/routes"
    line: "{{ item }}"
  with_items:
    - "#!/bin/bash" 
    - "[ \"$IFACE\" != {{ contrail_route[0].device }} ] && exit 0" 
  when: contrail_route

  
- name: "add static route"
#  sudo: True
  lineinfile:
    dest: "/etc/network/if-up.d/routes"
    line: "ip route add {{ item.ip }} via {{ item.gw }} dev {{ item.device }}"
    state: "present"
  with_items:
    - "{{ contrail_route }}"
  when: contrail_route