update
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
---
|
||||
## CentOS/RHEL/AlmaLinux specific variables
|
||||
# Use the fastestmirror yum plugin
|
||||
centos_fastestmirror_enabled: false
|
||||
|
||||
## Flatcar Container Linux specific variables
|
||||
# Disable locksmithd or leave it in its current state
|
||||
coreos_locksmithd_disable: false
|
||||
|
||||
## Oracle Linux specific variables
|
||||
# Install public repo on Oracle Linux
|
||||
use_oracle_public_repo: true
|
||||
|
||||
fedora_coreos_packages:
|
||||
- python
|
||||
- python3-libselinux
|
||||
- ethtool # required in kubeadm preflight phase for verifying the environment
|
||||
- ipset # required in kubeadm preflight phase for verifying the environment
|
||||
- conntrack-tools # required by kube-proxy
|
||||
|
||||
## General
|
||||
# Set the hostname to inventory_hostname
|
||||
override_system_hostname: true
|
||||
|
||||
is_fedora_coreos: false
|
||||
|
||||
skip_http_proxy_on_os_packages: false
|
||||
|
||||
# If this is true, debug information will be displayed but
|
||||
# may contain some private data, so it is recommended to set it to false
|
||||
# in the production environment.
|
||||
unsafe_show_logs: false
|
||||
42
kubespray/extra_playbooks/roles/bootstrap-os/files/bootstrap.sh
Executable file
42
kubespray/extra_playbooks/roles/bootstrap-os/files/bootstrap.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BINDIR="/opt/bin"
|
||||
if [[ -e $BINDIR/.bootstrapped ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
"x86_64")
|
||||
PYPY_ARCH=linux64
|
||||
PYPI_HASH=46818cb3d74b96b34787548343d266e2562b531ddbaf330383ba930ff1930ed5
|
||||
;;
|
||||
"aarch64")
|
||||
PYPY_ARCH=aarch64
|
||||
PYPI_HASH=2e1ae193d98bc51439642a7618d521ea019f45b8fb226940f7e334c548d2b4b9
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Architecture: ${ARCH}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
PYTHON_VERSION=3.9
|
||||
PYPY_VERSION=7.3.9
|
||||
PYPY_FILENAME="pypy${PYTHON_VERSION}-v${PYPY_VERSION}-${PYPY_ARCH}"
|
||||
PYPI_URL="https://downloads.python.org/pypy/${PYPY_FILENAME}.tar.bz2"
|
||||
|
||||
mkdir -p $BINDIR
|
||||
|
||||
cd $BINDIR
|
||||
|
||||
TAR_FILE=pyp.tar.bz2
|
||||
wget -O "${TAR_FILE}" "${PYPI_URL}"
|
||||
echo "${PYPI_HASH} ${TAR_FILE}" | sha256sum -c -
|
||||
tar -xjf "${TAR_FILE}" && rm "${TAR_FILE}"
|
||||
mv -n "${PYPY_FILENAME}" pypy3
|
||||
|
||||
ln -s ./pypy3/bin/pypy3 python
|
||||
$BINDIR/python --version
|
||||
|
||||
touch $BINDIR/.bootstrapped
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- name: RHEL auto-attach subscription
|
||||
command: /sbin/subscription-manager attach --auto
|
||||
become: true
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: no
|
||||
roles:
|
||||
- role: bootstrap-os
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ../../.yamllint .
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
platforms:
|
||||
- name: ubuntu16
|
||||
box: generic/ubuntu1604
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: ubuntu18
|
||||
box: generic/ubuntu1804
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: ubuntu20
|
||||
box: generic/ubuntu2004
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: centos7
|
||||
box: centos/7
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: almalinux8
|
||||
box: almalinux/8
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: debian9
|
||||
box: generic/debian9
|
||||
cpus: 1
|
||||
memory: 512
|
||||
- name: debian10
|
||||
box: generic/debian10
|
||||
cpus: 1
|
||||
memory: 512
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
callbacks_enabled: profile_tasks
|
||||
timeout: 120
|
||||
lint:
|
||||
name: ansible-lint
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
user:
|
||||
name: foo
|
||||
comment: My test comment
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
||||
@@ -0,0 +1,11 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']
|
||||
).get_hosts('all')
|
||||
|
||||
|
||||
def test_python(host):
|
||||
assert host.exists('python3') or host.exists('python')
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Enable EPEL repo for Amazon Linux
|
||||
yum_repository:
|
||||
name: epel
|
||||
file: epel
|
||||
description: Extra Packages for Enterprise Linux 7 - $basearch
|
||||
baseurl: http://download.fedoraproject.org/pub/epel/7/$basearch
|
||||
gpgcheck: yes
|
||||
gpgkey: http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
|
||||
skip_if_unavailable: yes
|
||||
enabled: yes
|
||||
repo_gpgcheck: no
|
||||
when: epel_enabled
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
- name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
|
||||
setup:
|
||||
gather_subset: '!all'
|
||||
filter: ansible_distribution_*version
|
||||
|
||||
- name: Add proxy to yum.conf or dnf.conf if http_proxy is defined
|
||||
ini_file:
|
||||
path: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('/etc/yum.conf','/etc/dnf/dnf.conf') }}"
|
||||
section: main
|
||||
option: proxy
|
||||
value: "{{ http_proxy | default(omit) }}"
|
||||
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
||||
no_extra_spaces: true
|
||||
mode: 0644
|
||||
become: true
|
||||
when: not skip_http_proxy_on_os_packages
|
||||
|
||||
# For Oracle Linux install public repo
|
||||
- name: Download Oracle Linux public yum repo
|
||||
get_url:
|
||||
url: https://yum.oracle.com/public-yum-ol7.repo
|
||||
dest: /etc/yum.repos.d/public-yum-ol7.repo
|
||||
when:
|
||||
- use_oracle_public_repo|default(true)
|
||||
- '''ID="ol"'' in os_release.stdout_lines'
|
||||
- (ansible_distribution_version | float) < 7.6
|
||||
environment: "{{ proxy_env }}"
|
||||
|
||||
- name: Enable Oracle Linux repo
|
||||
ini_file:
|
||||
dest: /etc/yum.repos.d/public-yum-ol7.repo
|
||||
section: "{{ item }}"
|
||||
option: enabled
|
||||
value: "1"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- ol7_latest
|
||||
- ol7_addons
|
||||
- ol7_developer_EPEL
|
||||
when:
|
||||
- use_oracle_public_repo|default(true)
|
||||
- '''ID="ol"'' in os_release.stdout_lines'
|
||||
- (ansible_distribution_version | float) < 7.6
|
||||
|
||||
- name: Install EPEL for Oracle Linux repo package
|
||||
package:
|
||||
name: "oracle-epel-release-el{{ ansible_distribution_major_version }}"
|
||||
state: present
|
||||
when:
|
||||
- use_oracle_public_repo|default(true)
|
||||
- '''ID="ol"'' in os_release.stdout_lines'
|
||||
- (ansible_distribution_version | float) >= 7.6
|
||||
|
||||
- name: Enable Oracle Linux repo
|
||||
ini_file:
|
||||
dest: "/etc/yum.repos.d/oracle-linux-ol{{ ansible_distribution_major_version }}.repo"
|
||||
section: "ol{{ ansible_distribution_major_version }}_addons"
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- { option: "name", value: "ol{{ ansible_distribution_major_version }}_addons" }
|
||||
- { option: "enabled", value: "1" }
|
||||
- { option: "baseurl", value: "http://yum.oracle.com/repo/OracleLinux/OL{{ ansible_distribution_major_version }}/addons/$basearch/" }
|
||||
when:
|
||||
- use_oracle_public_repo|default(true)
|
||||
- '''ID="ol"'' in os_release.stdout_lines'
|
||||
- (ansible_distribution_version | float) >= 7.6
|
||||
|
||||
- name: Enable Centos extra repo for Oracle Linux
|
||||
ini_file:
|
||||
dest: "/etc/yum.repos.d/centos-extras.repo"
|
||||
section: "extras"
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- { option: "name", value: "CentOS-{{ ansible_distribution_major_version }} - Extras" }
|
||||
- { option: "enabled", value: "1" }
|
||||
- { option: "gpgcheck", value: "0" }
|
||||
- { option: "baseurl", value: "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/extras/$basearch/{% if ansible_distribution_major_version|int > 7 %}os/{% endif %}" }
|
||||
when:
|
||||
- use_oracle_public_repo|default(true)
|
||||
- '''ID="ol"'' in os_release.stdout_lines'
|
||||
- (ansible_distribution_version | float) >= 7.6
|
||||
- (ansible_distribution_version | float) < 9
|
||||
|
||||
# CentOS ships with python installed
|
||||
|
||||
- name: Check presence of fastestmirror.conf
|
||||
stat:
|
||||
path: /etc/yum/pluginconf.d/fastestmirror.conf
|
||||
get_attributes: no
|
||||
get_checksum: no
|
||||
get_mime: no
|
||||
register: fastestmirror
|
||||
|
||||
# the fastestmirror plugin can actually slow down Ansible deployments
|
||||
- name: Disable fastestmirror plugin if requested
|
||||
lineinfile:
|
||||
dest: /etc/yum/pluginconf.d/fastestmirror.conf
|
||||
regexp: "^enabled=.*"
|
||||
line: "enabled=0"
|
||||
state: present
|
||||
become: true
|
||||
when:
|
||||
- fastestmirror.stat.exists
|
||||
- not centos_fastestmirror_enabled
|
||||
|
||||
# libselinux-python is required on SELinux enabled hosts
|
||||
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
|
||||
- name: Install libselinux python package
|
||||
package:
|
||||
name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
|
||||
state: present
|
||||
become: true
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
# ClearLinux ships with Python installed
|
||||
|
||||
- name: Install basic package to run containers
|
||||
package:
|
||||
name: containers-basic
|
||||
state: present
|
||||
|
||||
- name: Make sure docker service is enabled
|
||||
systemd:
|
||||
name: docker
|
||||
masked: false
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
state: started
|
||||
become: true
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
# CoreOS ships without Python installed
|
||||
|
||||
- name: Check if bootstrap is needed
|
||||
raw: stat /opt/bin/.bootstrapped
|
||||
register: need_bootstrap
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Force binaries directory for Container Linux by CoreOS and Flatcar
|
||||
set_fact:
|
||||
bin_dir: "/opt/bin"
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Run bootstrap.sh
|
||||
script: bootstrap.sh
|
||||
become: true
|
||||
environment: "{{ proxy_env }}"
|
||||
when:
|
||||
- need_bootstrap.rc != 0
|
||||
|
||||
- name: Set the ansible_python_interpreter fact
|
||||
set_fact:
|
||||
ansible_python_interpreter: "{{ bin_dir }}/python"
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Disable auto-upgrade
|
||||
systemd:
|
||||
name: locksmithd.service
|
||||
masked: true
|
||||
state: stopped
|
||||
when:
|
||||
- coreos_locksmithd_disable
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
# Some Debian based distros ship without Python installed
|
||||
|
||||
- name: Check if bootstrap is needed
|
||||
raw: which python3
|
||||
register: need_bootstrap
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
# This command should always run, even in check mode
|
||||
check_mode: false
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Check http::proxy in apt configuration files
|
||||
raw: apt-config dump | grep -qsi 'Acquire::http::proxy'
|
||||
register: need_http_proxy
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
# This command should always run, even in check mode
|
||||
check_mode: false
|
||||
|
||||
- name: Add http_proxy to /etc/apt/apt.conf if http_proxy is defined
|
||||
raw: echo 'Acquire::http::proxy "{{ http_proxy }}";' >> /etc/apt/apt.conf
|
||||
become: true
|
||||
when:
|
||||
- http_proxy is defined
|
||||
- need_http_proxy.rc != 0
|
||||
- not skip_http_proxy_on_os_packages
|
||||
|
||||
- name: Check https::proxy in apt configuration files
|
||||
raw: apt-config dump | grep -qsi 'Acquire::https::proxy'
|
||||
register: need_https_proxy
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
# This command should always run, even in check mode
|
||||
check_mode: false
|
||||
|
||||
- name: Add https_proxy to /etc/apt/apt.conf if https_proxy is defined
|
||||
raw: echo 'Acquire::https::proxy "{{ https_proxy }}";' >> /etc/apt/apt.conf
|
||||
become: true
|
||||
when:
|
||||
- https_proxy is defined
|
||||
- need_https_proxy.rc != 0
|
||||
- not skip_http_proxy_on_os_packages
|
||||
|
||||
- name: Install python3
|
||||
raw:
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-minimal
|
||||
become: true
|
||||
when:
|
||||
- need_bootstrap.rc != 0
|
||||
|
||||
- name: Update Apt cache
|
||||
raw: apt-get update --allow-releaseinfo-change
|
||||
become: true
|
||||
when:
|
||||
- '''ID=debian'' in os_release.stdout_lines'
|
||||
- '''VERSION_ID="10"'' in os_release.stdout_lines or ''VERSION_ID="11"'' in os_release.stdout_lines'
|
||||
register: bootstrap_update_apt_result
|
||||
changed_when:
|
||||
- '"changed its" in bootstrap_update_apt_result.stdout'
|
||||
- '"value from" in bootstrap_update_apt_result.stdout'
|
||||
ignore_errors: true
|
||||
|
||||
- name: Set the ansible_python_interpreter fact
|
||||
set_fact:
|
||||
ansible_python_interpreter: "/usr/bin/python3"
|
||||
|
||||
# Workaround for https://github.com/ansible/ansible/issues/25543
|
||||
- name: Install dbus for the hostname module
|
||||
package:
|
||||
name: dbus
|
||||
state: present
|
||||
use: apt
|
||||
become: true
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
|
||||
- name: Check if bootstrap is needed
|
||||
raw: which python
|
||||
register: need_bootstrap
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Remove podman network cni
|
||||
raw: "podman network rm podman"
|
||||
become: true
|
||||
ignore_errors: true # noqa ignore-errors
|
||||
when: need_bootstrap.rc != 0
|
||||
|
||||
- name: Clean up possible pending packages on fedora coreos
|
||||
raw: "export http_proxy={{ http_proxy | default('') }};rpm-ostree cleanup -p }}"
|
||||
become: true
|
||||
when: need_bootstrap.rc != 0
|
||||
|
||||
- name: Install required packages on fedora coreos
|
||||
raw: "export http_proxy={{ http_proxy | default('') }};rpm-ostree install --allow-inactive {{ fedora_coreos_packages|join(' ') }}"
|
||||
become: true
|
||||
when: need_bootstrap.rc != 0
|
||||
|
||||
- name: Reboot immediately for updated ostree
|
||||
raw: "nohup bash -c 'sleep 5s && shutdown -r now'"
|
||||
become: true
|
||||
ignore_errors: true # noqa ignore-errors
|
||||
ignore_unreachable: yes
|
||||
when: need_bootstrap.rc != 0
|
||||
|
||||
- name: Wait for the reboot to complete
|
||||
wait_for_connection:
|
||||
timeout: 240
|
||||
connect_timeout: 20
|
||||
delay: 5
|
||||
sleep: 5
|
||||
when: need_bootstrap.rc != 0
|
||||
|
||||
- name: Store the fact if this is an fedora core os host
|
||||
set_fact:
|
||||
is_fedora_coreos: True
|
||||
tags:
|
||||
- facts
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
# Some Fedora based distros ship without Python installed
|
||||
|
||||
- name: Check if bootstrap is needed
|
||||
raw: which python
|
||||
register: need_bootstrap
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Add proxy to dnf.conf if http_proxy is defined
|
||||
ini_file:
|
||||
path: "/etc/dnf/dnf.conf"
|
||||
section: main
|
||||
option: proxy
|
||||
value: "{{ http_proxy | default(omit) }}"
|
||||
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
||||
no_extra_spaces: true
|
||||
mode: 0644
|
||||
become: true
|
||||
when: not skip_http_proxy_on_os_packages
|
||||
|
||||
- name: Install python3 on fedora
|
||||
raw: "dnf install --assumeyes --quiet python3"
|
||||
become: true
|
||||
when:
|
||||
- need_bootstrap.rc != 0
|
||||
|
||||
# libselinux-python3 is required on SELinux enabled hosts
|
||||
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
|
||||
- name: Install libselinux-python3
|
||||
package:
|
||||
name: libselinux-python3
|
||||
state: present
|
||||
become: true
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
# Flatcar Container Linux ships without Python installed
|
||||
|
||||
- name: Check if bootstrap is needed
|
||||
raw: stat /opt/bin/.bootstrapped
|
||||
register: need_bootstrap
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
|
||||
set_fact:
|
||||
bin_dir: "/opt/bin"
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Run bootstrap.sh
|
||||
script: bootstrap.sh
|
||||
become: true
|
||||
environment: "{{ proxy_env }}"
|
||||
when:
|
||||
- need_bootstrap.rc != 0
|
||||
|
||||
- name: Set the ansible_python_interpreter fact
|
||||
set_fact:
|
||||
ansible_python_interpreter: "{{ bin_dir }}/python"
|
||||
tags:
|
||||
- facts
|
||||
|
||||
- name: Disable auto-upgrade
|
||||
systemd:
|
||||
name: locksmithd.service
|
||||
masked: true
|
||||
state: stopped
|
||||
when:
|
||||
- coreos_locksmithd_disable
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
# OpenSUSE ships with Python installed
|
||||
- name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
|
||||
setup:
|
||||
gather_subset: '!all'
|
||||
filter: ansible_distribution_*version
|
||||
|
||||
- name: Check that /etc/sysconfig/proxy file exists
|
||||
stat:
|
||||
path: /etc/sysconfig/proxy
|
||||
get_attributes: no
|
||||
get_checksum: no
|
||||
get_mime: no
|
||||
register: stat_result
|
||||
|
||||
- name: Create the /etc/sysconfig/proxy empty file
|
||||
file: # noqa risky-file-permissions
|
||||
path: /etc/sysconfig/proxy
|
||||
state: touch
|
||||
when:
|
||||
- http_proxy is defined or https_proxy is defined
|
||||
- not stat_result.stat.exists
|
||||
|
||||
- name: Set the http_proxy in /etc/sysconfig/proxy
|
||||
lineinfile:
|
||||
path: /etc/sysconfig/proxy
|
||||
regexp: '^HTTP_PROXY='
|
||||
line: 'HTTP_PROXY="{{ http_proxy }}"'
|
||||
become: true
|
||||
when:
|
||||
- http_proxy is defined
|
||||
|
||||
- name: Set the https_proxy in /etc/sysconfig/proxy
|
||||
lineinfile:
|
||||
path: /etc/sysconfig/proxy
|
||||
regexp: '^HTTPS_PROXY='
|
||||
line: 'HTTPS_PROXY="{{ https_proxy }}"'
|
||||
become: true
|
||||
when:
|
||||
- https_proxy is defined
|
||||
|
||||
- name: Enable proxies
|
||||
lineinfile:
|
||||
path: /etc/sysconfig/proxy
|
||||
regexp: '^PROXY_ENABLED='
|
||||
line: 'PROXY_ENABLED="yes"'
|
||||
become: true
|
||||
when:
|
||||
- http_proxy is defined or https_proxy is defined
|
||||
|
||||
# Required for zypper module
|
||||
- name: Install python-xml
|
||||
shell: zypper refresh && zypper --non-interactive install python-xml
|
||||
changed_when: false
|
||||
become: true
|
||||
tags:
|
||||
- facts
|
||||
|
||||
# Without this package, the get_url module fails when trying to handle https
|
||||
- name: Install python-cryptography
|
||||
zypper:
|
||||
name: python-cryptography
|
||||
state: present
|
||||
update_cache: true
|
||||
become: true
|
||||
when:
|
||||
- ansible_distribution_version is version('15.4', '<')
|
||||
|
||||
- name: Install python3-cryptography
|
||||
zypper:
|
||||
name: python3-cryptography
|
||||
state: present
|
||||
update_cache: true
|
||||
become: true
|
||||
when:
|
||||
- ansible_distribution_version is version('15.4', '>=')
|
||||
|
||||
# Nerdctl needs some basic packages to get an environment up
|
||||
- name: Install basic dependencies
|
||||
zypper:
|
||||
name:
|
||||
- iptables
|
||||
- apparmor-parser
|
||||
state: present
|
||||
become: true
|
||||
@@ -0,0 +1,121 @@
|
||||
---
|
||||
- name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
|
||||
setup:
|
||||
gather_subset: '!all'
|
||||
filter: ansible_distribution_*version
|
||||
|
||||
- name: Add proxy to yum.conf or dnf.conf if http_proxy is defined
|
||||
ini_file:
|
||||
path: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('/etc/yum.conf','/etc/dnf/dnf.conf') }}"
|
||||
section: main
|
||||
option: proxy
|
||||
value: "{{ http_proxy | default(omit) }}"
|
||||
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
||||
no_extra_spaces: true
|
||||
mode: 0644
|
||||
become: true
|
||||
when: not skip_http_proxy_on_os_packages
|
||||
|
||||
- name: Add proxy to RHEL subscription-manager if http_proxy is defined
|
||||
command: /sbin/subscription-manager config --server.proxy_hostname={{ http_proxy | regex_replace(':\d+$') }} --server.proxy_port={{ http_proxy | regex_replace('^.*:') }}
|
||||
become: true
|
||||
when:
|
||||
- not skip_http_proxy_on_os_packages
|
||||
- http_proxy is defined
|
||||
|
||||
- name: Check RHEL subscription-manager status
|
||||
command: /sbin/subscription-manager status
|
||||
register: rh_subscription_status
|
||||
changed_when: "rh_subscription_status != 0"
|
||||
ignore_errors: true # noqa ignore-errors
|
||||
become: true
|
||||
|
||||
- name: RHEL subscription Organization ID/Activation Key registration
|
||||
redhat_subscription:
|
||||
state: present
|
||||
org_id: "{{ rh_subscription_org_id }}"
|
||||
activationkey: "{{ rh_subscription_activation_key }}"
|
||||
auto_attach: true
|
||||
force_register: true
|
||||
syspurpose:
|
||||
usage: "{{ rh_subscription_usage }}"
|
||||
role: "{{ rh_subscription_role }}"
|
||||
service_level_agreement: "{{ rh_subscription_sla }}"
|
||||
sync: true
|
||||
notify: RHEL auto-attach subscription
|
||||
ignore_errors: true # noqa ignore-errors
|
||||
become: true
|
||||
when:
|
||||
- rh_subscription_org_id is defined
|
||||
- rh_subscription_status.changed
|
||||
|
||||
# this task has no_log set to prevent logging security sensitive information such as subscription passwords
|
||||
- name: RHEL subscription Username/Password registration
|
||||
redhat_subscription:
|
||||
state: present
|
||||
username: "{{ rh_subscription_username }}"
|
||||
password: "{{ rh_subscription_password }}"
|
||||
auto_attach: true
|
||||
force_register: true
|
||||
syspurpose:
|
||||
usage: "{{ rh_subscription_usage }}"
|
||||
role: "{{ rh_subscription_role }}"
|
||||
service_level_agreement: "{{ rh_subscription_sla }}"
|
||||
sync: true
|
||||
notify: RHEL auto-attach subscription
|
||||
ignore_errors: true # noqa ignore-errors
|
||||
become: true
|
||||
no_log: "{{ not (unsafe_show_logs|bool) }}"
|
||||
when:
|
||||
- rh_subscription_username is defined
|
||||
- rh_subscription_status.changed
|
||||
|
||||
# container-selinux is in extras repo
|
||||
- name: Enable RHEL 7 repos
|
||||
rhsm_repository:
|
||||
name:
|
||||
- "rhel-7-server-rpms"
|
||||
- "rhel-7-server-extras-rpms"
|
||||
state: enabled
|
||||
when:
|
||||
- rhel_enable_repos | default(True) | bool
|
||||
- ansible_distribution_major_version == "7"
|
||||
|
||||
# container-selinux is in appstream repo
|
||||
- name: Enable RHEL 8 repos
|
||||
rhsm_repository:
|
||||
name:
|
||||
- "rhel-8-for-*-baseos-rpms"
|
||||
- "rhel-8-for-*-appstream-rpms"
|
||||
state: enabled
|
||||
when:
|
||||
- rhel_enable_repos | default(True) | bool
|
||||
- ansible_distribution_major_version == "8"
|
||||
|
||||
- name: Check presence of fastestmirror.conf
|
||||
stat:
|
||||
path: /etc/yum/pluginconf.d/fastestmirror.conf
|
||||
get_attributes: no
|
||||
get_checksum: no
|
||||
get_mime: no
|
||||
register: fastestmirror
|
||||
|
||||
# the fastestmirror plugin can actually slow down Ansible deployments
|
||||
- name: Disable fastestmirror plugin if requested
|
||||
lineinfile:
|
||||
dest: /etc/yum/pluginconf.d/fastestmirror.conf
|
||||
regexp: "^enabled=.*"
|
||||
line: "enabled=0"
|
||||
state: present
|
||||
become: true
|
||||
when:
|
||||
- fastestmirror.stat.exists
|
||||
- not centos_fastestmirror_enabled
|
||||
|
||||
# libselinux-python is required on SELinux enabled hosts
|
||||
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
|
||||
- name: Install libselinux python package
|
||||
package:
|
||||
name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
|
||||
state: present
|
||||
become: true
|
||||
100
kubespray/extra_playbooks/roles/bootstrap-os/tasks/main.yml
Normal file
100
kubespray/extra_playbooks/roles/bootstrap-os/tasks/main.yml
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
- name: Fetch /etc/os-release
|
||||
raw: cat /etc/os-release
|
||||
register: os_release
|
||||
changed_when: false
|
||||
# This command should always run, even in check mode
|
||||
check_mode: false
|
||||
|
||||
- include_tasks: bootstrap-centos.yml
|
||||
when: '''ID="centos"'' in os_release.stdout_lines or ''ID="ol"'' in os_release.stdout_lines or ''ID="almalinux"'' in os_release.stdout_lines or ''ID="rocky"'' in os_release.stdout_lines or ''ID="kylin"'' in os_release.stdout_lines or ''ID="uos"'' in os_release.stdout_lines or ''ID="openEuler"'' in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-amazon.yml
|
||||
when: '''ID="amzn"'' in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-redhat.yml
|
||||
when: '''ID="rhel"'' in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-clearlinux.yml
|
||||
when: '''ID=clear-linux-os'' in os_release.stdout_lines'
|
||||
|
||||
# Fedora CoreOS
|
||||
- include_tasks: bootstrap-fedora-coreos.yml
|
||||
when:
|
||||
- '''ID=fedora'' in os_release.stdout_lines'
|
||||
- '''VARIANT_ID=coreos'' in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-flatcar.yml
|
||||
when: '''ID=flatcar'' in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-debian.yml
|
||||
when: '''ID=debian'' in os_release.stdout_lines or ''ID=ubuntu'' in os_release.stdout_lines'
|
||||
|
||||
# Fedora "classic"
|
||||
- include_tasks: bootstrap-fedora.yml
|
||||
when:
|
||||
- '''ID=fedora'' in os_release.stdout_lines'
|
||||
- '''VARIANT_ID=coreos'' not in os_release.stdout_lines'
|
||||
|
||||
- include_tasks: bootstrap-opensuse.yml
|
||||
when: '''ID="opensuse-leap"'' in os_release.stdout_lines or ''ID="opensuse-tumbleweed"'' in os_release.stdout_lines'
|
||||
|
||||
- name: Create remote_tmp for it is used by another module
|
||||
file:
|
||||
path: "{{ ansible_remote_tmp | default('~/.ansible/tmp') }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
# Workaround for https://github.com/ansible/ansible/issues/42726
|
||||
# (1/3)
|
||||
- name: Gather host facts to get ansible_os_family
|
||||
setup:
|
||||
gather_subset: '!all'
|
||||
filter: ansible_*
|
||||
|
||||
- name: Assign inventory name to unconfigured hostnames (non-CoreOS, non-Flatcar, Suse and ClearLinux, non-Fedora)
|
||||
hostname:
|
||||
name: "{{ inventory_hostname }}"
|
||||
when:
|
||||
- override_system_hostname
|
||||
- ansible_os_family not in ['Suse', 'Flatcar', 'Flatcar Container Linux by Kinvolk', 'ClearLinux']
|
||||
- not ansible_distribution == "Fedora"
|
||||
- not is_fedora_coreos
|
||||
|
||||
# (2/3)
|
||||
- name: Assign inventory name to unconfigured hostnames (CoreOS, Flatcar, Suse, ClearLinux and Fedora only)
|
||||
command: "hostnamectl set-hostname {{ inventory_hostname }}"
|
||||
register: hostname_changed
|
||||
become: true
|
||||
changed_when: false
|
||||
when: >
|
||||
override_system_hostname
|
||||
and (ansible_os_family in ['Suse', 'Flatcar', 'Flatcar Container Linux by Kinvolk', 'ClearLinux']
|
||||
or is_fedora_coreos
|
||||
or ansible_distribution == "Fedora")
|
||||
|
||||
# (3/3)
|
||||
- name: Update hostname fact (CoreOS, Flatcar, Suse, ClearLinux and Fedora only)
|
||||
setup:
|
||||
gather_subset: '!all'
|
||||
filter: ansible_hostname
|
||||
when: >
|
||||
override_system_hostname
|
||||
and (ansible_os_family in ['Suse', 'Flatcar', 'Flatcar Container Linux by Kinvolk', 'ClearLinux']
|
||||
or is_fedora_coreos
|
||||
or ansible_distribution == "Fedora")
|
||||
|
||||
- name: Install ceph-commmon package
|
||||
package:
|
||||
name:
|
||||
- ceph-common
|
||||
state: present
|
||||
when: rbd_provisioner_enabled|default(false)
|
||||
|
||||
- name: Ensure bash_completion.d folder exists
|
||||
file:
|
||||
name: /etc/bash_completion.d/
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
Reference in New Issue
Block a user