summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/configure-localhost.yml
blob: 0e3cde6ed147ad6c897c503b72e6856bd3b1113a (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2017 Ericsson AB 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: localhost
  connection: local

  pre_tasks:
    - name: Load distribution variables
      include_vars:
        file: "{{ item }}"
      failed_when: false
      with_items:
        - "{{ XCI_PATH }}/xci/var/opnfv.yml"
        - "{{ XCI_PATH }}/xci/var/{{ ansible_os_family }}.yml"

    - name: cleanup leftovers of previous deployment
      file:
        path: "{{ item }}"
        state: absent
        recurse: no
      with_items:
        - "{{ XCI_CACHE }}/repos"
        - "{{ LOG_PATH }} "
        - "{{ OPNFV_SSH_HOST_KEYS_PATH }}"

  roles:
    - role: clone-repository
      project: "openstack/openstack-ansible-openstack_openrc"
      repo: "{{ OPENSTACK_OSA_OPENRC_GIT_URL }}"
      dest: roles/openstack-ansible-openstack_openrc
      version: "master"
      when: INSTALLER_TYPE == "osa"
    - role: clone-repository
      project: "openstack/openstack-ansible"
      repo: "{{ OPENSTACK_OSA_GIT_URL }}"
      dest: "{{ XCI_CACHE }}/repos/openstack-ansible"
      version: "{{ OPENSTACK_OSA_VERSION }}"
      when: INSTALLER_TYPE == "osa"
    - role: clone-repository
      project: "kubernetes-incubator/kubespray"
      repo: "{{ KUBESPRAY_GIT_URL }}"
      dest: "{{ XCI_CACHE }}/repos/kubespray"
      version: "{{ KUBESPRAY_VERSION }}"
      when: INSTALLER_TYPE == "kubespray"
    - role: clone-repository
      project: "openstack/openstack-ansible-haproxy_server"
      repo: "{{ OPENSTACK_OSA_HAPROXY_GIT_URL }}"
      dest: roles/haproxy_server
      version: "{{ HAPROXY_VERSION }}"
      when:
        - INSTALLER_TYPE == "kubespray"
    - role: clone-repository
      project: "ansible-keepalived"
      repo: "{{ KEEPALIVED_GIT_URL }}"
      dest: roles/keepalived
      version: "{{ KEEPALIVED_VERSION }}"
      when:
        - INSTALLER_TYPE == "kubespray"

  tasks:
    - name:  create log directory {{LOG_PATH}}
      file:
        path: "{{LOG_PATH}}"
        state: directory
        recurse: no
    - block:
        - name: check if certificate directory /etc/ssl/certs exists already
          stat: path=/etc/ssl/certs
          register: check_etc_ssl_certs
        - name: create certificate directory /etc/ssl/certs
          become: true
          file:
            path: "/etc/ssl/certs"
            state: directory
          when: check_etc_ssl_certs.stat.exists == false
        - name: create key directory /etc/ssl/private
          become: true
          file:
            path: "/etc/ssl/private"
            state: directory
        - name: generate self signed certificate
          command: openssl req -new -nodes -x509 -subj "{{ XCI_SSL_SUBJECT }}" -days 3650 -keyout "/etc/ssl/private/xci.key" -out "/etc/ssl/certs/xci.crt" -extensions v3_ca
          become: true
        - name: Synchronize local development OSA repository to XCI paths
          # command module is much faster than the copy module
          synchronize:
            src: "{{ OPENSTACK_OSA_DEV_PATH }}"
            dest: "{{ XCI_CACHE }}/repos/openstack-ansible"
            recursive: yes
            delete: yes
          when:
            - OPENSTACK_OSA_DEV_PATH != ""
      when:
        - INSTALLER_TYPE == "osa"

    - name: Dump XCI execution environment to a file
      shell: env > "{{ XCI_PATH }}/.cache/xci.env"
      args:
        executable: /bin/bash