summaryrefslogtreecommitdiffstats
path: root/xci/infra/bifrost/playbooks/opnfv-virtual.yml
blob: f97eae4b3d927608015021a78a62882432a495ec (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2016 RedHat 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: opnfv
  name: "Host and Ironic bootstrapping"
  become: yes
  gather_facts: yes
  vars_files:
    - "../vars/{{ ansible_os_family | lower }}.yml"
  pre_tasks:
    - name: Remove pre-existing leases file
      file: path=/var/lib/misc/dnsmasq.leases state=absent
    - name: "Override the ipv4_gateway setting"
      set_fact:
         ipv4_gateway: "192.168.122.1"
    - name: Prepare the XCI pre-built images
      block:
        - name: Create the PXE directory
          file:
            path: /httpboot
            state: directory
        - name: Download the {{ xci_distro }} image checksum file
          get_url:
            dest: /httpboot/deployment_image.qcow2.sha256.txt
            force: no
            url: http://artifacts.opnfv.org/releng/xci/images/{{ xci_distro }}.qcow2.sha256.txt
            timeout: 3000
        - name: Extract checksum
          shell: awk '{print $1}' /httpboot/deployment_image.qcow2.sha256.txt
          register: _image_checksum
        - fail:
            msg: "Failed to get image checksum"
          when: _image_checksum == ''
        - set_fact:
            image_checksum: "{{ _image_checksum.stdout }}"
        - name: Download the {{ xci_distro }} image file
          get_url:
            url: http://artifacts.opnfv.org/releng/xci/images/{{ xci_distro }}.qcow2
            checksum: "sha256:{{ image_checksum }}"
            timeout: 3000
            dest: /httpboot/deployment_image.qcow2
            force: no
        - name: Set correct mode for {{ xci_distro }}.qcow2 file
          file:
            path: /httpboot/deployment_image.qcow2
            mode: '0755'
            owner: 'root'
            group: 'root'
      when: create_image_via_dib | bool == false
    - name: Ensure /etc/hosts has good defaults
      lineinfile:
        create: yes
        dest: "/etc/hosts"
        regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*"
        line: "{{ item.contents }}"
      with_items:
        - { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' }
        - { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' }
    - name: Install required packages
      package:
        name: "{{ bifrost_required_devel_packages }}"
        state: present

  roles:
    - role: bifrost-prep-for-install
      when: skip_install is not defined
    - role: bifrost-keystone-install
    - role: bifrost-ironic-install
      cleaning: false
      testing: false
      enabled_hardware_types: ipmi
      network_interface: "{{ ansible_default_ipv4.interface }}"
      # Create the IPA image for ironic to boot the nodes and write the final distro in the hard drive
      # fedora is used because it is the only one working with ericsson-pod2 (it has support for newer hardware)
    - role: bifrost-create-dib-image
      dib_imagename: "{{ http_boot_folder }}/ipa"
      build_ramdisk: false
      dib_os_element: "{{ ipa_dib_os_element|default('fedora') }}"
      dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}"
      dib_notmpfs: true
      when:
        - create_ipa_image | bool == true
      # Create the final distro image
    - role: bifrost-create-dib-image
      dib_imagetype: "qcow2"
      dib_imagename: "{{deploy_image}}"
      dib_env_vars:
        DIB_PYTHON_VERSION: 2
      dib_os_element: "{{ lookup('env','DIB_OS_ELEMENT') }}"
      dib_os_release: "{{ lookup('env', 'DIB_OS_RELEASE') }}"
      extra_dib_elements: "{{ lookup('env', 'EXTRA_DIB_ELEMENTS') | default('') }}"
      dib_elements: "vm enable-serial-console simple-init devuser openssh-server growroot pip-and-virtualenv {{ extra_dib_elements }}"
      dib_packages: "{{ lookup('env', 'DIB_OS_PACKAGES') }}"
      dib_notmpfs: true
      when:
        - create_image_via_dib | bool == true
        - transform_boot_image | bool == false
    - role: bifrost-keystone-client-config
      clouds:
        bifrost:
          config_username: "{{ ironic.keystone.default_username }}"
          config_password: "{{ ironic.keystone.default_password }}"
          config_project_name: "baremetal"
          config_region_name: "{{ keystone.bootstrap.region_name }}"
          config_auth_url: "{{ keystone.bootstrap.public_url }}"
  environment:
    http_proxy: "{{ lookup('env','http_proxy') }}"
    https_proxy: "{{ lookup('env','https_proxy') }}"
    no_proxy: "{{ lookup('env','no_proxy') }}"

- hosts: baremetal
  name: "Enrollment and Deployment"
  vars:
    multinode_testing: "{{ inventory_dhcp | bool == true }}"
  become: no
  gather_facts: False
  tasks:
    - name: Gathering facts
      setup:
      delegate_to: opnfv
      delegate_facts: False
    - name: Find network interface in the OPNFV node
      set_fact:
        network_interface: "{{ ansible_default_ipv4.interface }}"
    - import_role:
        name: ironic-enroll-dynamic
        private: True
      delegate_to: opnfv
    - import_role:
        name: ironic-inspect-node
        private: True
      delegate_to: opnfv
      when: inspect_nodes | default('false') | bool == true
    - import_role:
        name: bifrost-configdrives-dynamic
        private: True
      vars:
        ipv4_nameserver: "{{ host_info[inventory_hostname]['public']['dns'] | list }}"
      delegate_to: opnfv
    - import_role:
        name: bifrost-deploy-nodes-dynamic
        private: True
      delegate_to: opnfv
  environment:
    http_proxy: "{{ lookup('env','http_proxy') }}"
    https_proxy: "{{ lookup('env','https_proxy') }}"
    no_proxy: "{{ lookup('env','no_proxy') }}"

- hosts: baremetal
  name: "Deploy machines."
  become: no
  serial: 1
  gather_facts: False
  tasks:
      #- name: Gathering facts
      #setup:
      #delegate_to: opnfv
      #delegate_facts: False
    - import_role:
        name: bifrost-prepare-for-test-dynamic
      delegate_to: opnfv