dsk-dev kubespray 이동
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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,50 @@
|
||||
# Ansible Role: GlusterFS
|
||||
|
||||
[](https://travis-ci.org/geerlingguy/ansible-role-glusterfs)
|
||||
|
||||
Installs and configures GlusterFS on Linux.
|
||||
|
||||
## Requirements
|
||||
|
||||
For GlusterFS to connect between servers, TCP ports `24007`, `24008`, and `24009`/`49152`+ (that port, plus an additional incremented port for each additional server in the cluster; the latter if GlusterFS is version 3.4+), and TCP/UDP port `111` must be open. You can open these using whatever firewall you wish (this can easily be configured using the `geerlingguy.firewall` role).
|
||||
|
||||
This role performs basic installation and setup of Gluster, but it does not configure or mount bricks (volumes), since that step is easier to do in a series of plays in your own playbook. Ansible 1.9+ includes the [`gluster_volume`](https://docs.ansible.com/ansible/latest/collections/gluster/gluster/gluster_volume_module.html) module to ease the management of Gluster volumes.
|
||||
|
||||
## Role Variables
|
||||
|
||||
Available variables are listed below, along with default values (see `defaults/main.yml`):
|
||||
|
||||
```yaml
|
||||
glusterfs_default_release: ""
|
||||
```
|
||||
|
||||
You can specify a `default_release` for apt on Debian/Ubuntu by overriding this variable. This is helpful if you need a different package or version for the main GlusterFS packages (e.g. GlusterFS 3.5.x instead of 3.2.x with the `wheezy-backports` default release on Debian Wheezy).
|
||||
|
||||
```yaml
|
||||
glusterfs_ppa_use: yes
|
||||
glusterfs_ppa_version: "3.5"
|
||||
```
|
||||
|
||||
For Ubuntu, specify whether to use the official Gluster PPA, and which version of the PPA to use. See Gluster's [Getting Started Guide](https://docs.gluster.org/en/latest/Quick-Start-Guide/Quickstart/) for more info.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
```yaml
|
||||
- hosts: server
|
||||
roles:
|
||||
- geerlingguy.glusterfs
|
||||
```
|
||||
|
||||
For a real-world use example, read through [Simple GlusterFS Setup with Ansible](http://www.jeffgeerling.com/blog/simple-glusterfs-setup-ansible), a blog post by this role's author, which is included in Chapter 8 of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||
|
||||
## License
|
||||
|
||||
MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
This role was created in 2015 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
# For Ubuntu.
|
||||
glusterfs_default_release: ""
|
||||
glusterfs_ppa_use: yes
|
||||
glusterfs_ppa_version: "4.1"
|
||||
|
||||
# Gluster configuration.
|
||||
gluster_mount_dir: /mnt/gluster
|
||||
gluster_volume_node_mount_dir: /mnt/xfs-drive-gluster
|
||||
gluster_brick_dir: "{{ gluster_volume_node_mount_dir }}/brick"
|
||||
gluster_brick_name: gluster
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: GlusterFS installation for Linux.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 2.0
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- precise
|
||||
- trusty
|
||||
- xenial
|
||||
- name: Debian
|
||||
versions:
|
||||
- wheezy
|
||||
- jessie
|
||||
galaxy_tags:
|
||||
- system
|
||||
- networking
|
||||
- cloud
|
||||
- clustering
|
||||
- files
|
||||
- sharing
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
# This is meant for Ubuntu and RedHat installations, where apparently the glusterfs-client is not used from inside
|
||||
# hyperkube and needs to be installed as part of the system.
|
||||
|
||||
# Setup/install tasks.
|
||||
- include: setup-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat' and groups['gfs-cluster'] is defined
|
||||
|
||||
- include: setup-Debian.yml
|
||||
when: ansible_os_family == 'Debian' and groups['gfs-cluster'] is defined
|
||||
|
||||
- name: Ensure Gluster mount directories exist.
|
||||
file: "path={{ item }} state=directory mode=0775"
|
||||
with_items:
|
||||
- "{{ gluster_mount_dir }}"
|
||||
when: ansible_os_family in ["Debian","RedHat"] and groups['gfs-cluster'] is defined
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: Add PPA for GlusterFS.
|
||||
apt_repository:
|
||||
repo: 'ppa:gluster/glusterfs-{{ glusterfs_ppa_version }}'
|
||||
state: present
|
||||
update_cache: yes
|
||||
register: glusterfs_ppa_added
|
||||
when: glusterfs_ppa_use
|
||||
|
||||
- name: Ensure GlusterFS client will reinstall if the PPA was just added. # noqa 503
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- glusterfs-client
|
||||
when: glusterfs_ppa_added.changed
|
||||
|
||||
- name: Ensure GlusterFS client is installed.
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
default_release: "{{ glusterfs_default_release }}"
|
||||
with_items:
|
||||
- glusterfs-client
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Install Prerequisites
|
||||
package: name={{ item }} state=present
|
||||
with_items:
|
||||
- "centos-release-gluster{{ glusterfs_default_release }}"
|
||||
|
||||
- name: Install Packages
|
||||
package: name={{ item }} state=present
|
||||
with_items:
|
||||
- glusterfs-client
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# For Ubuntu.
|
||||
glusterfs_default_release: ""
|
||||
glusterfs_ppa_use: yes
|
||||
glusterfs_ppa_version: "3.12"
|
||||
|
||||
# Gluster configuration.
|
||||
gluster_mount_dir: /mnt/gluster
|
||||
gluster_volume_node_mount_dir: /mnt/xfs-drive-gluster
|
||||
gluster_brick_dir: "{{ gluster_volume_node_mount_dir }}/brick"
|
||||
gluster_brick_name: gluster
|
||||
# Default device to mount for xfs formatting, terraform overrides this by setting the variable in the inventory.
|
||||
disk_volume_device_1: /dev/vdb
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: GlusterFS installation for Linux.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 2.0
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- precise
|
||||
- trusty
|
||||
- xenial
|
||||
- name: Debian
|
||||
versions:
|
||||
- wheezy
|
||||
- jessie
|
||||
galaxy_tags:
|
||||
- system
|
||||
- networking
|
||||
- cloud
|
||||
- clustering
|
||||
- files
|
||||
- sharing
|
||||
@@ -0,0 +1,94 @@
|
||||
---
|
||||
# Include variables and define needed variables.
|
||||
- name: Include OS-specific variables.
|
||||
include_vars: "{{ ansible_os_family }}.yml"
|
||||
|
||||
# Install xfs package
|
||||
- name: install xfs Debian
|
||||
apt: name=xfsprogs state=present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: install xfs RedHat
|
||||
package: name=xfsprogs state=present
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
# Format external volumes in xfs
|
||||
- name: Format volumes in xfs
|
||||
filesystem: "fstype=xfs dev={{ disk_volume_device_1 }}"
|
||||
|
||||
# Mount external volumes
|
||||
- name: mounting new xfs filesystem
|
||||
mount: "name={{ gluster_volume_node_mount_dir }} src={{ disk_volume_device_1 }} fstype=xfs state=mounted"
|
||||
|
||||
# Setup/install tasks.
|
||||
- include: setup-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- include: setup-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Ensure GlusterFS is started and enabled at boot.
|
||||
service: "name={{ glusterfs_daemon }} state=started enabled=yes"
|
||||
|
||||
- name: Ensure Gluster brick and mount directories exist.
|
||||
file: "path={{ item }} state=directory mode=0775"
|
||||
with_items:
|
||||
- "{{ gluster_brick_dir }}"
|
||||
- "{{ gluster_mount_dir }}"
|
||||
|
||||
- name: Configure Gluster volume with replicas
|
||||
gluster_volume:
|
||||
state: present
|
||||
name: "{{ gluster_brick_name }}"
|
||||
brick: "{{ gluster_brick_dir }}"
|
||||
replicas: "{{ groups['gfs-cluster'] | length }}"
|
||||
cluster: "{% for item in groups['gfs-cluster'] -%}{{ hostvars[item]['ip']|default(hostvars[item].ansible_default_ipv4['address']) }}{% if not loop.last %},{% endif %}{%- endfor %}"
|
||||
host: "{{ inventory_hostname }}"
|
||||
force: yes
|
||||
run_once: true
|
||||
when: groups['gfs-cluster']|length > 1
|
||||
|
||||
- name: Configure Gluster volume without replicas
|
||||
gluster_volume:
|
||||
state: present
|
||||
name: "{{ gluster_brick_name }}"
|
||||
brick: "{{ gluster_brick_dir }}"
|
||||
cluster: "{% for item in groups['gfs-cluster'] -%}{{ hostvars[item]['ip']|default(hostvars[item].ansible_default_ipv4['address']) }}{% if not loop.last %},{% endif %}{%- endfor %}"
|
||||
host: "{{ inventory_hostname }}"
|
||||
force: yes
|
||||
run_once: true
|
||||
when: groups['gfs-cluster']|length <= 1
|
||||
|
||||
- name: Mount glusterfs to retrieve disk size
|
||||
mount:
|
||||
name: "{{ gluster_mount_dir }}"
|
||||
src: "{{ ip|default(ansible_default_ipv4['address']) }}:/gluster"
|
||||
fstype: glusterfs
|
||||
opts: "defaults,_netdev"
|
||||
state: mounted
|
||||
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
|
||||
|
||||
- name: Get Gluster disk size
|
||||
setup: filter=ansible_mounts
|
||||
register: mounts_data
|
||||
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
|
||||
|
||||
- name: Set Gluster disk size to variable
|
||||
set_fact:
|
||||
gluster_disk_size_gb: "{{ (mounts_data.ansible_facts.ansible_mounts | selectattr('mount', 'equalto', gluster_mount_dir) | map(attribute='size_total') | first | int / (1024*1024*1024)) | int }}"
|
||||
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
|
||||
|
||||
- name: Create file on GlusterFS
|
||||
template:
|
||||
dest: "{{ gluster_mount_dir }}/.test-file.txt"
|
||||
src: test-file.txt
|
||||
mode: 0644
|
||||
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
|
||||
|
||||
- name: Unmount glusterfs
|
||||
mount:
|
||||
name: "{{ gluster_mount_dir }}"
|
||||
fstype: glusterfs
|
||||
src: "{{ ip|default(ansible_default_ipv4['address']) }}:/gluster"
|
||||
state: unmounted
|
||||
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Add PPA for GlusterFS.
|
||||
apt_repository:
|
||||
repo: 'ppa:gluster/glusterfs-{{ glusterfs_ppa_version }}'
|
||||
state: present
|
||||
update_cache: yes
|
||||
register: glusterfs_ppa_added
|
||||
when: glusterfs_ppa_use
|
||||
|
||||
- name: Ensure GlusterFS will reinstall if the PPA was just added. # noqa 503
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- glusterfs-server
|
||||
- glusterfs-client
|
||||
when: glusterfs_ppa_added.changed
|
||||
|
||||
- name: Ensure GlusterFS is installed.
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
default_release: "{{ glusterfs_default_release }}"
|
||||
with_items:
|
||||
- glusterfs-server
|
||||
- glusterfs-client
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Install Prerequisites
|
||||
package: name={{ item }} state=present
|
||||
with_items:
|
||||
- "centos-release-gluster{{ glusterfs_default_release }}"
|
||||
|
||||
- name: Install Packages
|
||||
package: name={{ item }} state=present
|
||||
with_items:
|
||||
- glusterfs-server
|
||||
- glusterfs-client
|
||||
@@ -0,0 +1 @@
|
||||
test file
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
glusterfs_daemon: glusterd
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
glusterfs_daemon: glusterd
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Kubernetes Apps | Lay Down k8s GlusterFS Endpoint and PV
|
||||
template:
|
||||
src: "{{ item.file }}"
|
||||
dest: "{{ kube_config_dir }}/{{ item.dest }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- { file: glusterfs-kubernetes-endpoint.json.j2, type: ep, dest: glusterfs-kubernetes-endpoint.json}
|
||||
- { file: glusterfs-kubernetes-pv.yml.j2, type: pv, dest: glusterfs-kubernetes-pv.yml}
|
||||
- { file: glusterfs-kubernetes-endpoint-svc.json.j2, type: svc, dest: glusterfs-kubernetes-endpoint-svc.json}
|
||||
register: gluster_pv
|
||||
when: inventory_hostname == groups['kube_control_plane'][0] and groups['gfs-cluster'] is defined and hostvars[groups['gfs-cluster'][0]].gluster_disk_size_gb is defined
|
||||
|
||||
- name: Kubernetes Apps | Set GlusterFS endpoint and PV
|
||||
kube:
|
||||
name: glusterfs
|
||||
namespace: default
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
resource: "{{ item.item.type }}"
|
||||
filename: "{{ kube_config_dir }}/{{ item.item.dest }}"
|
||||
state: "{{ item.changed | ternary('latest','present') }}"
|
||||
with_items: "{{ gluster_pv.results }}"
|
||||
when: inventory_hostname == groups['kube_control_plane'][0] and groups['gfs-cluster'] is defined
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "glusterfs"
|
||||
},
|
||||
"spec": {
|
||||
"ports": [
|
||||
{"port": 1}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"kind": "Endpoints",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "glusterfs"
|
||||
},
|
||||
"subsets": [
|
||||
{% for host in groups['gfs-cluster'] %}
|
||||
{
|
||||
"addresses": [
|
||||
{
|
||||
"ip": "{{hostvars[host]['ip']|default(hostvars[host].ansible_default_ipv4['address'])}}"
|
||||
}
|
||||
],
|
||||
"ports": [
|
||||
{
|
||||
"port": 1
|
||||
}
|
||||
]
|
||||
}{%- if not loop.last %}, {% endif -%}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: glusterfs
|
||||
spec:
|
||||
capacity:
|
||||
storage: "{{ hostvars[groups['gfs-cluster'][0]].gluster_disk_size_gb }}Gi"
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
glusterfs:
|
||||
endpoints: glusterfs
|
||||
path: gluster
|
||||
readOnly: false
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- {role: kubernetes-pv/ansible, tags: apps}
|
||||
Reference in New Issue
Block a user