blob: 5d5ac49ca2ed1965f2ed1290ed65f9cef0253228 [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:
30 False # orchestration.stat.exists == True # XXX
31 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:
49 False # (orchestration.stat.exists == True) and (onos_apps.stat.exists == True) # XXX
50
51# ---- alternatively, check out repos from Internet ---
52
53- name: Clone service-profile repo
Zack Williams35624562016-08-28 17:12:26 -070054 git:
Scott Bakerdb5c8c72016-11-08 08:40:06 -080055 repo={{ service_profile_repo_url }}
56 dest={{ service_profile_repo_dest }}
57 version={{ service_profile_repo_branch }}
58 force=yes
59 when:
60 True # orchestration.stat.exists == False # XXX
61
62# ---- install keys ----
63
64- name: Copy over SSH keys
65 command: cp ~/.ssh/{{ item }} {{ service_profile_repo_dest }}/{{ xos_configuration }}/
66 with_items:
67 - id_rsa
68 - id_rsa.pub
69 tags:
70 - skip_ansible_lint
71
72- name: Copy over node key
73 command: cp {{ ansible_user_dir }}/node_key {{ service_profile_repo_dest }}/{{ xos_configuration }}/
74 tags:
75 - skip_ansible_lint
76
77- name: Set ownership and permissions of keys
78 file:
79 path={{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }}
80 owner={{ ansible_user_id }}
81# mode=0600
82 with_items:
83 - id_rsa
84 - id_rsa.pub
85 - node_key
86
87# ----
88
89- name: Download Glance VM images
90 get_url:
91 url={{ item.url }}
92 checksum={{ item.checksum }}
93 dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.img
94 with_items: "{{ xos_images }}"
95
96# ---- pull docker images ----
97
98- name: Check to see if registry is reachable
99 command: curl -sf http://docker-registry:5000/
100 ignore_errors: yes
101 register: docker_registry_check
102 tags:
103 - skip_ansible_lint
104
105- name: Use registry if it is available
106 set_fact:
107 docker_registry: "{{ local_docker_registry }}"
108 docker_opts: "--insecure-registry {{ local_docker_registry }}"
109 docker_tag: "candidate"
110 when: docker_registry_check|succeeded
111
112- name: Pull docker images for XOS
113 become: yes
114 command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }}
115 with_items:
116 - xosproject/xos-base
117 - xosproject/xos-postgres
118 - xosproject/cord-app-build
119 - redis
120 tags:
121 - skip_ansible_lint
122
123- name: Tag the images downloaded from the local registry
124 command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest
125 with_items:
126 - xosproject/xos-base
127 - xosproject/xos-postgres
128 - xosproject/cord-app-build
129 - redis
130 when: docker_registry_check|succeeded
131
132# ---- optional: rebuild base container ----
Scott Baker333a3152016-06-29 08:58:42 -0700133
Zack Williamsc563b572016-06-03 09:49:53 -0700134- name: Rebuild XOS containers
135 when: xos_container_rebuild
Scott Bakerdb5c8c72016-11-08 08:40:06 -0800136 command: make {{ item }}
137 chdir="{{ xos_repo_dest }}/containers/xos/"
Zack Williams72a9ab42016-06-08 08:32:49 -0700138 with_items:
Scott Bakerdb5c8c72016-11-08 08:40:06 -0800139 - base
Zack Williamsc563b572016-06-03 09:49:53 -0700140
Scott Bakerdb5c8c72016-11-08 08:40:06 -0800141
142
Zack Williamsd2cbe512016-06-03 09:33:15 -0700143