2021-02-13 14:20:18 +01:00
|
|
|
---
|
|
|
|
# tasks file for bootstrap
|
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Import assert.yml
|
|
|
|
ansible.builtin.import_tasks: assert.yml
|
2021-02-13 14:20:18 +01:00
|
|
|
run_once: yes
|
|
|
|
delegate_to: localhost
|
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Wait for port to be available
|
|
|
|
ansible.builtin.wait_for:
|
2021-02-13 14:20:18 +01:00
|
|
|
port: "{{ ansible_port | default('22') }}"
|
2023-02-17 12:06:35 +01:00
|
|
|
timeout: "{{ bootstrap_timeout }}"
|
2021-02-13 14:20:18 +01:00
|
|
|
become: no
|
|
|
|
when:
|
|
|
|
- ansible_connection is defined
|
2023-02-17 12:06:35 +01:00
|
|
|
- ansible_connection not in [ "container", "docker", "community.docker.docker" ]
|
2021-02-13 14:20:18 +01:00
|
|
|
- bootstrap_wait_for_host | bool
|
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Prepare system
|
|
|
|
# At this stage, python and/or sudo are not installed, `become` can't be used.
|
|
|
|
become: no
|
2021-02-13 14:20:18 +01:00
|
|
|
block:
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Test connection
|
|
|
|
ansible.builtin.wait_for_connection:
|
2021-02-13 14:20:18 +01:00
|
|
|
timeout: "{{ bootstrap_timeout }}"
|
|
|
|
register: bootstrap_connect
|
|
|
|
changed_when: no
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Test sudo
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: sudo --version
|
|
|
|
changed_when: no
|
2021-02-13 14:20:18 +01:00
|
|
|
rescue:
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Gather bootstrap facts
|
|
|
|
ansible.builtin.include_tasks:
|
|
|
|
file: gather_facts.yml
|
2021-02-13 14:20:18 +01:00
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Install bootstrap packages (raw)
|
|
|
|
ansible.builtin.raw: "{{ bootstrap_install.raw }}"
|
2021-02-13 14:20:18 +01:00
|
|
|
register: bootstrap_install_packages
|
|
|
|
changed_when:
|
|
|
|
- (bootstrap_install.stdout_regex in bootstrap_install_packages.stdout and
|
|
|
|
bootstrap_os_family in [ "Alpine", "Archlinux", "Gentoo" ]) or
|
|
|
|
(bootstrap_install.stdout_regex not in bootstrap_install_packages.stdout and
|
2023-02-17 12:06:35 +01:00
|
|
|
bootstrap_os_family in [ "Debian", "RedHat", "Rocky", "Suse" ])
|
2021-02-13 14:20:18 +01:00
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Gather ansible facts
|
|
|
|
ansible.builtin.setup:
|
|
|
|
become: no
|
2021-02-13 14:20:18 +01:00
|
|
|
|
2023-02-17 12:06:35 +01:00
|
|
|
- name: Install bootstrap packages (package)
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
loop: "{{ bootstrap_facts_packages.split() }}"
|
|
|
|
become: "{{ bootstrap_become }}"
|