Browse Source
Define and implement specs for bootstrap-os (#4455)
Define and implement specs for bootstrap-os (#4455)
* Add README to bootstrap-os role * Rework bootstrap-os once more * Document workarounds for bugs/deficiencies in Ansible modules * Unify and document role variables * Remove installation of additional packages and repositories * Merge Ubuntu and Debian tasks * Remove pipelining setting from default playbooks * Fix OpenSUSE not running its required taskspull/4450/head
MarkusTeufelberger
5 years ago
committed by
Kubernetes Prow Robot
12 changed files with 174 additions and 228 deletions
Split View
Diff Options
-
4cluster.yml
-
59roles/bootstrap-os/README.md
-
24roles/bootstrap-os/defaults/main.yml
-
76roles/bootstrap-os/tasks/bootstrap-centos.yml
-
14roles/bootstrap-os/tasks/bootstrap-clearlinux.yml
-
33roles/bootstrap-os/tasks/bootstrap-coreos.yml
-
26roles/bootstrap-os/tasks/bootstrap-debian.yml
-
40roles/bootstrap-os/tasks/bootstrap-fedora.yml
-
15roles/bootstrap-os/tasks/bootstrap-opensuse.yml
-
72roles/bootstrap-os/tasks/bootstrap-ubuntu.yml
-
37roles/bootstrap-os/tasks/main.yml
-
2scale.yml
@ -0,0 +1,59 @@ |
|||
# bootstrap-os |
|||
|
|||
Bootstrap an Ansible host to be able to run Ansible modules. |
|||
|
|||
This role will: |
|||
* configure the package manager (if applicable) to be able to fetch packages |
|||
* install Python |
|||
* install the necessary packages to use Ansible's package manager modules |
|||
* set the hostname of the host to `{{ inventory_hostname }}` when requested |
|||
|
|||
## Requirements |
|||
|
|||
A host running an operating system that is supported by Kubespray. |
|||
See https://github.com/kubernetes-sigs/kubespray#supported-linux-distributions for a current list. |
|||
|
|||
SSH access to the host. |
|||
|
|||
## Role Variables |
|||
|
|||
Variables are listed with their default values, if applicable. |
|||
|
|||
### General variables |
|||
|
|||
* `http_proxy`/`https_proxy` |
|||
The role will configure the package manager (if applicable) to download packages via a proxy. |
|||
This is currently implemented for CentOS/RHEL (`http_proxy` only) as well as Debian and Ubuntu (both `http_proxy` and `https_proxy` are respected) |
|||
|
|||
* `override_system_hostname: true` |
|||
The role will set the hostname of the machine to the name it has according to Ansible's inventory (the variable `{{ inventory_hostname }}`). |
|||
|
|||
### Per distribution variables |
|||
|
|||
#### CoreOS |
|||
|
|||
* `coreos_locksmithd_disable: false` |
|||
Whether `locksmithd` (responsible for rolling restarts) should be disabled or be left alone. |
|||
|
|||
#### CentOS/RHEL |
|||
|
|||
* `centos_fastestmirror_enabled: false` |
|||
Whether the [fastestmirror](https://wiki.centos.org/PackageManagement/Yum/FastestMirror) yum plugin should be enabled. |
|||
|
|||
## Dependencies |
|||
|
|||
The `kubespray-defaults` role is expected to be run before this role. |
|||
|
|||
## Example Playbook |
|||
|
|||
Remember to disable fact gathering since Python might not be present on hosts. |
|||
|
|||
- hosts: all |
|||
gather_facts: false # not all hosts might be able to run modules yet |
|||
roles: |
|||
- kubespray-defaults |
|||
- bootstrap-os |
|||
|
|||
## License |
|||
|
|||
Apache 2.0 |
@ -1,16 +1,14 @@ |
|||
--- |
|||
pip_python_coreos_modules: |
|||
- httplib2 |
|||
- six |
|||
|
|||
override_system_hostname: true |
|||
coreos_auto_upgrade: true |
|||
|
|||
## CentOS/RHEL specific variables |
|||
# Install epel repo on Centos/RHEL |
|||
epel_enabled: false |
|||
centos_epel_enabled: false |
|||
# Use the fastestmirror yum plugin |
|||
centos_fastestmirror_enabled: false |
|||
|
|||
# CentOS/RedHat Extras repo |
|||
extras_rh_repo_base_url: "http://mirror.centos.org/centos/$releasever/extras/$basearch/" |
|||
extras_rh_repo_gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7" |
|||
# Caching extras packages after installation |
|||
extras_rh_rpm_keepcache: 0 |
|||
## CoreOS specific variables |
|||
# Disable locksmithd or leave it in its current state |
|||
coreos_locksmithd_disable: false |
|||
|
|||
## General |
|||
# Set the hostname to inventory_hostname |
|||
override_system_hostname: true |
@ -1,16 +1,16 @@ |
|||
--- |
|||
- name: Install basic packages to run containers |
|||
# ClearLinux ships with Python installed |
|||
|
|||
- name: Install basic package to run containers |
|||
package: |
|||
name: "{{ item }}" |
|||
name: containers-basic |
|||
state: present |
|||
with_items: |
|||
- containers-basic |
|||
|
|||
- name: Make sure docker service is enabled |
|||
systemd: |
|||
name: docker |
|||
masked: no |
|||
enabled: yes |
|||
daemon_reload: yes |
|||
masked: false |
|||
enabled: true |
|||
daemon_reload: true |
|||
state: started |
|||
become: true |
@ -1,22 +1,46 @@ |
|||
--- |
|||
# Some Fedora based distros ship without Python installed |
|||
|
|||
- name: Check if this is an atomic host |
|||
raw: stat /run/ostree-booted |
|||
register: ostree |
|||
environment: {} |
|||
failed_when: false |
|||
changed_when: false |
|||
tags: |
|||
- facts |
|||
|
|||
- name: Store the fact if this is an atomic host |
|||
set_fact: |
|||
is_atomic: "{{ ostree.rc == 0 }}" |
|||
tags: |
|||
- facts |
|||
|
|||
- name: Check if bootstrap is needed |
|||
raw: which "{{ item }}" |
|||
raw: which python |
|||
register: need_bootstrap |
|||
failed_when: false |
|||
changed_when: false |
|||
with_items: |
|||
- python |
|||
environment: {} |
|||
tags: facts |
|||
tags: |
|||
- facts |
|||
|
|||
# Fedora's policy as of Fedora 30 is to still install python2 as /usr/bin/python |
|||
# See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 for the current status |
|||
- name: Install python on fedora |
|||
raw: "dnf install --assumeyes --quiet python" |
|||
raw: "dnf install --assumeyes --quiet python2" |
|||
become: true |
|||
environment: {} |
|||
when: need_bootstrap.results | map(attribute='rc') | sort | last | bool |
|||
when: |
|||
- need_bootstrap.rc != 0 |
|||
- not is_atomic |
|||
|
|||
- name: Install required python packages |
|||
dnf: |
|||
# 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: |
|||
name: libselinux-python |
|||
state: present |
|||
become: true |
|||
when: |
|||
- not is_atomic |
@ -1,13 +1,10 @@ |
|||
--- |
|||
- name: Ensure zypper cache is updated (SUSE) |
|||
zypper_repository: |
|||
repo: "*" |
|||
runrefresh: yes |
|||
# OpenSUSE ships with Python installed |
|||
|
|||
- name: Install required packages (SUSE) |
|||
package: |
|||
name: "{{ item }}" |
|||
# Without this package, the get_url module fails when trying to handle https |
|||
- name: Install python-cryptography |
|||
zypper: |
|||
name: python-cryptography |
|||
state: present |
|||
with_items: |
|||
- python-cryptography |
|||
update_cache: true |
|||
become: true |
@ -1,72 +0,0 @@ |
|||
--- |
|||
- name: List ubuntu_packages |
|||
set_fact: |
|||
ubuntu_packages: |
|||
- python |
|||
- python-apt |
|||
- python-pip |
|||
- dbus |
|||
|
|||
- name: Check if bootstrap is needed |
|||
raw: dpkg -l | cut -d' ' -f3 | grep -e ^{{ item }}$ |
|||
register: need_bootstrap |
|||
failed_when: false |
|||
changed_when: false |
|||
# This command should always run, even in check mode |
|||
check_mode: false |
|||
with_items: "{{ ubuntu_packages }}" |
|||
environment: {} |
|||
tags: |
|||
- facts |
|||
|
|||
- name: Check http::proxy in /etc/apt/apt.conf |
|||
raw: grep -qsi 'Acquire::http::proxy' /etc/apt/apt.conf |
|||
register: need_http_proxy |
|||
failed_when: false |
|||
changed_when: false |
|||
# This command should always run, even in check mode |
|||
check_mode: false |
|||
environment: {} |
|||
when: |
|||
- http_proxy is defined |
|||
|
|||
- 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 |
|||
environment: {} |
|||
when: |
|||
- http_proxy is defined |
|||
- need_http_proxy.rc != 0 |
|||
|
|||
- name: Check https::proxy in /etc/apt/apt.conf |
|||
raw: grep -qsi 'Acquire::https::proxy' /etc/apt/apt.conf |
|||
register: need_https_proxy |
|||
failed_when: false |
|||
changed_when: false |
|||
# This command should always run, even in check mode |
|||
check_mode: false |
|||
environment: {} |
|||
when: |
|||
- https_proxy is defined |
|||
|
|||
- 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 |
|||
environment: {} |
|||
when: |
|||
- https_proxy is defined |
|||
- need_https_proxy.rc != 0 |
|||
|
|||
- name: Install python and pip |
|||
raw: |
|||
apt-get update && \ |
|||
DEBIAN_FRONTEND=noninteractive apt-get install -y {{ ubuntu_packages | join(" ") }} |
|||
become: true |
|||
environment: {} |
|||
when: |
|||
- need_bootstrap.results | map(attribute='rc') | sort | last | bool |
|||
|
|||
- set_fact: |
|||
ansible_python_interpreter: "/usr/bin/python" |
|||
tags: |
|||
- facts |
Write
Preview
Loading…
Cancel
Save