summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/configure-localhost.yml
blob: 7aab18f3879c802e7de6a3bf8f5a5fa69341ee5d (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
106
107
108
109
110
111
112
113
114
115
116
---
# 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:
        - "{{ 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 in ["kubespray", "osh"]
    - 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" or installer_type == "osh"
    - role: clone-repository
      project: "ansible-keepalived"
      repo: "{{ keepalived_git_url }}"
      dest: roles/keepalived
      version: "{{ keepalived_version }}"
      when:
        - installer_type == "kubespray" or installer_type == "osh"

  tasks:
    - name:  create log directory {{log_path}}
      file:
        path: "{{log_path}}"
        state: directory
        recurse: no

    - 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 != ""
        - installer_type == "osa"

    - name: Configure SSH key for local user
      user:
        name: "{{ ansible_env.USER }}"
        createhome: yes
        home: "/home/{{ ansible_env.USER }}"
        move_home: yes
        shell: /bin/bash
        generate_ssh_key: yes
        ssh_key_bits: 2048
        ssh_key_comment: xci
        ssh_key_type: rsa
        ssh_key_file: .ssh/id_rsa
        state: present

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

    #TODO: Create an Ansible variable for
    #      kube_service_addresses(10.233.0.0/18)
    - name: Update iptables
      command: "iptables -t nat -I POSTROUTING 3 -s 192.168.122.0/24 -d 10.233.0.0/18 -j RETURN"
      become: true
      tags:
        - skip_ansible_lint

    #Provide access to the external network (for tests)
    - name: Update iptables
      command: "iptables -t nat -I POSTROUTING 3 -s 192.168.122.0/24 -d 172.24.4.0/24 -j RETURN"
      become: true
      tags:
        - skip_ansible_lint