blob: b48901c22f2b6b8e44acb39af2585d426d008330 [file] [log] [blame]
Luca Prete8d4e8bc2016-08-24 14:49:54 -07001---
2#
3# Installs ONOS and downloads the related dependencies. It then compiles the code.
4#
5- name: Installing Maven
6 apt:
7 name: maven
8 force: yes
9 tags: [common]
10
11- name: Creating Application folder
12 file:
13 path: "{{ app_dir }}"
14 state: directory
15 mode: 0777
16
17- name: Creating Download folder
18 file:
19 path: "{{ download_dir }}"
20 state: directory
21 mode: 0777
22
23- name: Downloading Apache Karaf
24 get_url:
25 url: "http://archive.apache.org/dist/karaf/{{ karaf_version }}/apache-karaf-{{ karaf_version }}.tar.gz"
26 dest: "{{ download_dir }}"
27 mode: 0777
28
29- name: Copying Apache Karaf in the Application directory
30 copy:
31 src: "/home/ubuntu/{{ download_dir }}/apache-karaf-{{ karaf_version }}.tar.gz"
32 dest: "/home/ubuntu/{{ app_dir }}/apache-karaf-{{ karaf_version }}.tar.gz"
33 mode: 0777
34
35- name: Extracting Apache Karaf
36 unarchive:
37 src: "/home/ubuntu/{{ download_dir }}/apache-karaf-{{ karaf_version }}.tar.gz"
38 dest: "/home/ubuntu/{{ app_dir }}"
39 mode: 0777
40
41- name: Cloning ONOS repository
42 git:
43 repo: "{{ onos_repo_url }}"
44 dest: onos
45 version: onos-"{{ onos_version }}"
46 become: true
47 become_user: ubuntu
48
49- name: Changing ONOS repository permissions
50 file:
51 path: "/home/ubuntu/onos"
52 state: directory
53 owner: ubuntu
54 group: ubuntu
55 mode: 0777
56
57- name: Exporting ONOS variables
58 lineinfile:
59 dest: /home/ubuntu/.bashrc
60 line: "{{ item }}"
61 with_items: "{{ onos_variables }}"
62
63- name: Compiling ONOS
64 shell: "{{ item }}"
65 args:
66 chdir: "/home/ubuntu/onos"
67 with_items:
68 - mvn clean install
69 become: true
70 become_user: ubuntu
71
72- name: Changing .m2 repository permissions
73 file:
74 path: "/home/ubuntu/.m2"
75 state: directory
76 owner: ubuntu
77 group: ubuntu
78 mode: 0777
79
80- name: Creating 1 node ONOS cell
81 template:
82 src: templates/one_node_cell.j2
83 dest: "{{ cell_files[0] }}"
84 owner: ubuntu
85 group: ubuntu
86 mode: 0777
87
88- name: Creating 3 node ONOS cell
89 template:
90 src: templates/three_node_cell.j2
91 dest: "{{ cell_files[1] }}"
92 owner: ubuntu
93 group: ubuntu
94 mode: 0777
95
96- name: Creating ONOS deployment script
97 template:
98 src: templates/onos_deploy.j2
99 dest: "/home/ubuntu/onos_deploy.sh"
100 owner: ubuntu
101 group: ubuntu
102 mode: 0777
103
104- name: Deploying ONOS
105 shell: "/home/ubuntu/onos_deploy.sh"
106 environment:
107 ONOS_ROOT: /home/ubuntu/onos
108 args:
109 executable: /bin/bash
110 become: true
111 become_user: ubuntu
112
113- name: Adding ONOS to startup
114 become: yes
115 shell: "lxc-attach --name {{ item.value.name }} -- systemctl enable onos"
116 with_dict: "{{ lxc }}"