blob: ffa4f9dcf71e1479431790ccbf966f9322b21e36 [file] [log] [blame]
Zack Williamsfc102dd2016-03-01 17:31:30 -07001---
2# tasks for xos-install role
3
Scott Bakerdb5c8c72016-11-08 08:40:06 -08004- name: Install prerequisites
5 apt:
6 name={{ item }}
7 update_cache=yes
8 cache_valid_time=3600
9 become: yes
10 with_items:
11 - git
12 - make
13 - curl
14 - python-novaclient
15 - python-neutronclient
16 - python-keystoneclient
17 - python-glanceclient
Zack Williamsd2cbe512016-06-03 09:33:15 -070018
Scott Bakerdb5c8c72016-11-08 08:40:06 -080019# ---- copy repos from the dev machine to the head node ----
20
21- name: Check to see if orchestration directory exists
22 local_action: stat path="{{ playbook_dir }}/../../orchestration"
23 register: orchestration
24
25- name: Copy repositories to the head node
26 synchronize:
27 src: "{{ playbook_dir }}/../../orchestration/{{ item }}"
28 dest: "{{ ansible_user_dir }}/"
29 when:
Scott Bakerf9eac1c2016-11-22 12:01:42 -080030 False # orchestration.stat.exists == True # XXX
Scott Bakerdb5c8c72016-11-08 08:40:06 -080031 with_items:
32 - service-profile
33 - xos
34 - xos_libraries
35 - xos_services
36
37- name: Check to see if onos_apps directory exists
38 local_action: stat path="{{ playbook_dir }}/../../onos-apps/apps"
39 register: onos_apps
40
41- name: Copy in onos-apps that have XOS code
42 synchronize:
43 src: "{{ playbook_dir }}/../../onos-apps/apps/{{ item }}"
44 dest: "{{ ansible_user_dir }}/xos_services/"
45 with_items:
46 - vtn
47 - olt
48 when:
Scott Bakerf9eac1c2016-11-22 12:01:42 -080049 False # (orchestration.stat.exists == True) and (onos_apps.stat.exists == True) # XXX
Zack Williams682450e2016-11-19 09:04:41 -070050
Scott Bakerdb5c8c72016-11-08 08:40:06 -080051
52# ---- alternatively, check out repos from Internet ---
53
54- name: Clone service-profile repo
Zack Williams35624562016-08-28 17:12:26 -070055 git:
Scott Bakerdb5c8c72016-11-08 08:40:06 -080056 repo={{ service_profile_repo_url }}
57 dest={{ service_profile_repo_dest }}
58 version={{ service_profile_repo_branch }}
59 force=yes
60 when:
Scott Bakerf9eac1c2016-11-22 12:01:42 -080061 True # orchestration.stat.exists == False # XXX
Scott Bakerdb5c8c72016-11-08 08:40:06 -080062
63# ---- install keys ----
64
65- name: Copy over SSH keys
66 command: cp ~/.ssh/{{ item }} {{ service_profile_repo_dest }}/{{ xos_configuration }}/
67 with_items:
68 - id_rsa
69 - id_rsa.pub
70 tags:
71 - skip_ansible_lint
72
73- name: Copy over node key
74 command: cp {{ ansible_user_dir }}/node_key {{ service_profile_repo_dest }}/{{ xos_configuration }}/
75 tags:
76 - skip_ansible_lint
77
78- name: Set ownership and permissions of keys
79 file:
80 path={{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }}
81 owner={{ ansible_user_id }}
82# mode=0600
83 with_items:
84 - id_rsa
85 - id_rsa.pub
86 - node_key
87
Zack Williams682450e2016-11-19 09:04:41 -070088- name: Create templated TOSCA files
89 template:
90 src: "{{ item }}.j2"
91 dest: "{{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }}"
92 with_items: "{{ xos_tosca_templates }}"
Scott Bakerdb5c8c72016-11-08 08:40:06 -080093
94- name: Download Glance VM images
95 get_url:
96 url={{ item.url }}
97 checksum={{ item.checksum }}
Zack Williams682450e2016-11-19 09:04:41 -070098 dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.qcow2
Scott Bakerdb5c8c72016-11-08 08:40:06 -080099 with_items: "{{ xos_images }}"
100
101# ---- pull docker images ----
102
103- name: Check to see if registry is reachable
104 command: curl -sf http://docker-registry:5000/
105 ignore_errors: yes
106 register: docker_registry_check
107 tags:
108 - skip_ansible_lint
109
110- name: Use registry if it is available
111 set_fact:
112 docker_registry: "{{ local_docker_registry }}"
113 docker_opts: "--insecure-registry {{ local_docker_registry }}"
114 docker_tag: "candidate"
115 when: docker_registry_check|succeeded
116
117- name: Pull docker images for XOS
118 become: yes
119 command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }}
120 with_items:
121 - xosproject/xos-base
122 - xosproject/xos-postgres
123 - xosproject/cord-app-build
124 - redis
125 tags:
126 - skip_ansible_lint
127
128- name: Tag the images downloaded from the local registry
129 command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest
130 with_items:
131 - xosproject/xos-base
132 - xosproject/xos-postgres
133 - xosproject/cord-app-build
134 - redis
135 when: docker_registry_check|succeeded
136
Zack Williamsc563b572016-06-03 09:49:53 -0700137
Scott Bakerdb5c8c72016-11-08 08:40:06 -0800138
139
Zack Williamsd2cbe512016-06-03 09:33:15 -0700140