68d3e73e3e4a6
[infra/engine.git] / engine / infra / bifrost / playbooks / roles / install-configure-bifrost / templates / bifrost-install.yml.j2
1 ---
2 {% raw %}
3 - hosts: target
4   name: "Install Ironic on the target host."
5   become: yes
6   gather_facts: yes
7   vars:
8 {% endraw %}
9     multinode_testing: true
10     enabled_hardware_types: ipmi
11     enable_keystone: false
12     cleaning: false
13     testing: false
14     create_image_via_dib: true
15     download_ipa: "{{ download_ipa }}"
16     create_ipa_image: "{{ create_ipa_image }}"
17     ipa_dib_os_element: "{{ ipa_dib_os_element }}"
18     ironic_git_branch: "{{ ironic_version }}"
19     ironicclient_source_install: false
20     ironicinspector_source_install: false
21     ironicinspectorclient_source_install: false
22     network_interface: "{{ engine.pxe_interface }}"
23     inventory_dhcp: true
24     inventory_dhcp_static_ip: true
25 {% raw %}
26   roles:
27     - { role: bifrost-prep-for-install, when: skip_install is not defined }
28     - role: bifrost-keystone-install
29     - role: bifrost-ironic-install
30     - role: bifrost-keystone-client-config
31       user: "{{ ansible_env.SUDO_USER | default(ansible_user_id) }}"
32       clouds:
33         bifrost:
34           config_username: "{{ ironic.keystone.default_username }}"
35           config_password: "{{ ironic.keystone.default_password }}"
36           config_project_name: "baremetal"
37           config_region_name: "{{ keystone.bootstrap.region_name }}"
38           config_auth_url: "{{ keystone.bootstrap.public_url }}"
39         bifrost-admin:
40           config_username: "{{ keystone.bootstrap.username }}"
41           config_password: "{{ keystone.bootstrap.password }}"
42           config_project_name: "{{ keystone.bootstrap.project_name }}"
43           config_region_name: "{{ keystone.bootstrap.region_name }}"
44           config_auth_url: "{{ keystone.bootstrap.public_url }}"
45     - role: bifrost-create-dib-image
46       dib_imagename: "{{ http_boot_folder }}/ipa"
47       build_ramdisk: false
48       dib_os_element: "{{ ipa_dib_os_element }}"
49       dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}"
50       when: create_ipa_image | bool == true
51     - role: bifrost-create-dib-image
52       dib_imagetype: "qcow2"
53       dib_imagename: "{{deploy_image}}"
54       dib_env_vars:
55         DIB_PYTHON_VERSION: 2
56 {% endraw %}
57       dib_os_element: "{{ dib_os_element }}"
58       dib_os_release: "{{ dib_os_release }}"
59       dib_packages: "{{ dib_os_packages }}"
60 {% raw %}
61       extra_dib_elements: "{{ lookup('env', 'EXTRA_DIB_ELEMENTS') | default('') }}"
62       dib_elements: "vm enable-serial-console simple-init devuser openssh-server growroot pip-and-virtualenv {{ extra_dib_elements }}"
63       dib_notmpfs: true
64       when:
65         - create_image_via_dib | bool == true
66         - transform_boot_image | bool == false
67   environment:
68     http_proxy: "{{ lookup('env','http_proxy') }}"
69     https_proxy: "{{ lookup('env','https_proxy') }}"
70     no_proxy: "{{ lookup('env', 'no_proxy') }}"
71
72 - hosts: localhost
73   connection: local
74   become: yes
75   gather_facts: no
76   tasks:
77     - name: Add deploy_logs_collect field into Ironic configuration file
78       blockinfile:
79         dest: /etc/ironic/ironic.conf
80         marker: "# {mark} SET IRONIC TROUBLESHOTTING PARAMETER"
81         block: |
82           [agent]
83           deploy_logs_collect = always
84       when: "{{ lookup('env', 'VERBOSITY') }} == true"
85
86     - name: Restart Ironic service
87       service:
88         name: "{{ item }}"
89         state: restarted
90       with_items:
91         - ironic-api
92         - ironic-conductor
93         - ironic-inspector
94       when:
95         - "{{ lookup('env', 'VERBOSITY') }} == true"
96
97 - hosts: localhost
98   connection: local
99   become: no
100   gather_facts: no
101   tasks:
102     - name: Get nodes from Ironic
103       command: openstack --os-cloud bifrost baremetal node list
104       register: ironic_nodes
105     - name: List Ironic nodes
106       debug:
107         msg: "{{ ironic_nodes.stdout_lines }}"
108 {% endraw %}