57 lines
1.9 KiB
YAML
57 lines
1.9 KiB
YAML
---
|
|
# tasks file for bootstrap
|
|
- name: Wait for host
|
|
wait_for:
|
|
port: "{{ ansible_port | default('22') }}"
|
|
host: "{{ (ansible_ssh_host | default(ansible_host) | default(inventory_hostname)) }}"
|
|
connection: local
|
|
become: no
|
|
when:
|
|
- ansible_connection is defined
|
|
- ansible_connection != "docker"
|
|
- bootstrap_wait_for_host | bool
|
|
|
|
- name: Prepare system
|
|
block:
|
|
- name: Test connection
|
|
wait_for_connection:
|
|
timeout: "{{ bootstrap_timeout }}"
|
|
register: bootstrap_connect
|
|
changed_when: no
|
|
rescue:
|
|
- name: Gather bootstrap facts
|
|
include_tasks: "gather_facts.yml"
|
|
|
|
- name: Install bootstrap packages
|
|
raw: "{{ bootstrap_install.raw }}"
|
|
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
|
|
bootstrap_os_family in ['Debian', 'RedHat', 'Suse'])
|
|
until: bootstrap_install_packages is succeeded
|
|
retries: "{{ bootstrap_retries }}"
|
|
vars:
|
|
ansible_user: "{{ bootstrap_user }}"
|
|
always:
|
|
- name: Set bootstrap ansible_user
|
|
set_fact:
|
|
bootstrap_ansible_user: "{{ ansible_user | default(omit) if bootstrap_connect is succeeded else bootstrap_user }}"
|
|
changed_when: no
|
|
|
|
- name: Ensure system is prepared
|
|
block:
|
|
- name: Gather ansible facts
|
|
setup:
|
|
|
|
- name: Install bootstrap packages
|
|
package:
|
|
name: "{{ item }}"
|
|
state: present
|
|
loop: "{{ bootstrap_facts_packages.split() }}"
|
|
register: bootstrap_install_facts_packages
|
|
until: bootstrap_install_facts_packages is succeeded
|
|
retries: "{{ bootstrap_retries }}"
|
|
vars:
|
|
ansible_user: "{{ bootstrap_ansible_user | default(omit) }}"
|