blob: a4bdbf07040025db85c51adf8b3f258d1ca7e1bf (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# 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: opnfv
remote_user: root
vars_files:
- "{{ xci_path }}/xci/var/opnfv.yml"
tasks:
- name: Load distribution variables
include_vars:
file: "{{ item }}"
with_items:
- "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml"
- name: Set facts for remote deployment
set_fact:
remote_xci_path: "{{ ansible_env.HOME }}/releng-xci"
remote_xci_flavor_files: "{{ ansible_env.HOME }}/releng-xci/xci/installer/{{ installer_type }}/files/{{ xci_flavor }}"
remote_xci_playbooks: "{{ ansible_env.HOME }}/releng-xci/xci/playbooks"
- name: Copy releng-xci to remote host
synchronize:
src: "{{ xci_path }}/"
dest: "{{ remote_xci_path }}"
recursive: yes
delete: yes
- name: generate SSH keys
command: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
args:
creates: /root/.ssh/id_rsa
- name: add id_rsa.pub to authorized_keys
shell: cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
when: xci_flavor == 'aio'
- name: fetch public key
fetch:
src: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub"
dest: "{{ xci_path }}/xci/files/authorized_keys"
flat: yes
- name: delete the opnfv_inventory directory
file:
path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
state: absent
- name: copy kubespray inventory directory
command: "cp -rf {{ remote_xci_flavor_files }}/inventory \
{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
args:
creates: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory"
- name: make sure kubespray/opnfv_inventory/group_vars/ exist
file:
path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
state: directory
- name: copy k8s_cluster.yml
command: "cp -rf {{ remote_xci_path }}/xci/installer/kubespray/files/k8s-cluster.yml \
{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars"
args:
creates: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars/k8s-cluster.yml"
- name: Install required packages
package:
name: "{{ kube_require_packages[ansible_pkg_mgr] }}"
state: present
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
when: xci_flavor == 'aio'
- name: change dashboard server type to NodePort
lineinfile:
path: "{{ remote_xci_path }}/.cache/repos/kubespray/roles/kubernetes-apps/ansible/templates/dashboard.yml.j2"
insertafter: 'targetPort'
line: " type: NodePort"
- name: pip install ansible
pip:
name: ansible
version: "{{ xci_kube_ansible_pip_version }}"
- hosts: localhost
remote_user: root
vars_files:
- "{{ xci_path }}/xci/var/opnfv.yml"
tasks:
- name: Append public keys to authorized_keys
shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> {{ xci_path }}/xci/files/authorized_keys"
changed_when: True
|