4 Commits

Author SHA1 Message Date
Timothy Stewart cb704edc42 chore(docs): Updated with collections command 2022-09-14 20:56:12 -05:00
Timothy Stewart 21d6e15ff3 chore(docs): Fixing thanks section 2022-09-14 20:49:58 -05:00
Timothy Stewart 7c70c5a6a8 chore(docs): Updated with ansible utils 2022-09-14 20:48:28 -05:00
Timothy Stewart e9198c60e8 chore(docs): Updated with ansible utils 2022-09-14 20:35:45 -05:00
35 changed files with 97 additions and 575 deletions
-1
View File
@@ -12,4 +12,3 @@
- [ ] Ran `reset.yml` playbook - [ ] Ran `reset.yml` playbook
- [ ] Did not add any unnecessary changes - [ ] Did not add any unnecessary changes
- [ ] 🚀 - [ ] 🚀
- [ ] Ran pre-commit install at least once before committing
-37
View File
@@ -1,37 +0,0 @@
#!/bin/bash
# download-boxes.sh
# Check all molecule.yml files for required Vagrant boxes and download the ones that are not
# already present on the system.
set -euo pipefail
GIT_ROOT=$(git rev-parse --show-toplevel)
PROVIDER=virtualbox
# Read all boxes for all platforms from the "molecule.yml" files
all_boxes=$(cat "${GIT_ROOT}"/molecule/*/molecule.yml |
yq -r '.platforms[].box' | # Read the "box" property of each node under "platforms"
grep --invert-match --regexp=--- | # Filter out file separators
sort |
uniq)
# Read the boxes that are currently present on the system (for the current provider)
present_boxes=$(
(vagrant box list |
grep "${PROVIDER}" | # Filter by boxes available for the current provider
awk '{print $1;}' | # The box name is the first word in each line
sort |
uniq) ||
echo "" # In case any of these commands fails, just use an empty list
)
# The boxes that we need to download are the ones present in $all_boxes, but not $present_boxes.
download_boxes=$(comm -2 -3 <(echo "${all_boxes}") <(echo "${present_boxes}"))
# Actually download the necessary boxes
if [ -n "${download_boxes}" ]; then
echo "${download_boxes}" | while IFS= read -r box; do
vagrant box add --provider "${PROVIDER}" "${box}"
done
fi
+13 -56
View File
@@ -5,69 +5,26 @@ on:
push: push:
branches: branches:
- master - master
paths-ignore:
- '**/README.md'
jobs: jobs:
pre-commit-ci: ansible-lint:
name: Pre-Commit name: YAML Lint + Ansible Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.10"
steps: steps:
- name: Check out the codebase - name: Check out the codebase
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
- name: Set up Python 3.x
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 #4.0.2
with: with:
ref: ${{ github.event.pull_request.head.sha }} python-version: '3.x'
- name: Set up Python ${{ env.PYTHON_VERSION }} - name: Install test dependencies
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # 4.3.0 run: pip3 install yamllint ansible-lint ansible
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies
- name: Cache pip - name: Run yamllint
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11 run: yamllint .
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Ansible - name: Run ansible-lint
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11 run: ansible-lint
with:
path: ~/.ansible/collections
key: ${{ runner.os }}-ansible-${{ hashFiles('collections/requirements.txt') }}
restore-keys: |
${{ runner.os }}-ansible-
- name: Install dependencies
run: |
echo "::group::Upgrade pip"
python3 -m pip install --upgrade pip
echo "::endgroup::"
echo "::group::Install Python requirements from requirements.txt"
python3 -m pip install -r requirements.txt
echo "::endgroup::"
echo "::group::Install Ansible role requirements from collections/requirements.yml"
ansible-galaxy install -r collections/requirements.yml
echo "::endgroup::"
- name: Run pre-commit
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # 3.0.0
ensure-pinned-actions:
name: Ensure SHA Pinned Actions
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@6ca5574367befbc9efdb2fa25978084159c5902d # 1.3.0
with:
allowlist: |
aws-actions/
docker/login-action
+6 -31
View File
@@ -5,8 +5,7 @@ on:
push: push:
branches: branches:
- master - master
paths-ignore:
- '**/README.md'
jobs: jobs:
molecule: molecule:
name: Molecule name: Molecule
@@ -25,8 +24,6 @@ jobs:
steps: steps:
- name: Check out the codebase - name: Check out the codebase
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2 uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Configure VirtualBox - name: Configure VirtualBox
run: |- run: |-
@@ -36,16 +33,8 @@ jobs:
* fdad:bad:ba55::/64 * fdad:bad:ba55::/64
EOF EOF
- name: Cache pip
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Vagrant boxes - name: Cache Vagrant boxes
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11 uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # 3.0.8
with: with:
path: | path: |
~/.vagrant.d/boxes ~/.vagrant.d/boxes
@@ -53,27 +42,15 @@ jobs:
restore-keys: | restore-keys: |
vagrant-boxes vagrant-boxes
- name: Download Vagrant boxes for all scenarios
# To save some cache space, all scenarios share the same cache key.
# On the other hand, this means that the cache contents should be
# the same across all scenarios. This step ensures that.
run: ./.github/download-boxes.sh
- name: Set up Python ${{ env.PYTHON_VERSION }} - name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # 4.3.0 uses: actions/setup-python@v2
with: with:
python-version: ${{ env.PYTHON_VERSION }} python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies
- name: Install dependencies - name: Install dependencies
run: | run: >-
echo "::group::Upgrade pip" python3 -m pip install --upgrade pip &&
python3 -m pip install --upgrade pip
echo "::endgroup::"
echo "::group::Install Python requirements from requirements.txt"
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
echo "::endgroup::"
- name: Test with molecule - name: Test with molecule
run: molecule test --scenario-name ${{ matrix.scenario }} run: molecule test --scenario-name ${{ matrix.scenario }}
@@ -81,12 +58,10 @@ jobs:
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }} ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
ANSIBLE_SSH_RETRIES: 4 ANSIBLE_SSH_RETRIES: 4
ANSIBLE_TIMEOUT: 60 ANSIBLE_TIMEOUT: 60
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
- name: Upload log files - name: Upload log files
if: always() # do this even if a step before has failed if: always() # do this even if a step before has failed
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # 3.1.1 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
with: with:
name: logs name: logs
path: | path: |
-1
View File
@@ -1,2 +1 @@
.env/ .env/
*.log
-21
View File
@@ -1,21 +0,0 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: requirements-txt-fixer
- id: sort-simple-yaml
- id: detect-private-key
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
hooks:
- id: yamllint
args: [-c=.yamllint]
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.8.2
hooks:
- id: ansible-lint
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
hooks:
- id: shellcheck
+4 -4
View File
@@ -16,9 +16,9 @@ If you want more context on how this works, see:
Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a HA Kubernetes cluster on machines running: Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a HA Kubernetes cluster on machines running:
- [x] Debian (tested on version 11) - [X] Debian
- [x] Ubuntu (tested on version 22.04) - [X] Ubuntu
- [x] Rocky (tested on version 9) - [X] CentOS
on processor architecture: on processor architecture:
@@ -34,7 +34,7 @@ on processor architecture:
- `server` and `agent` nodes should have passwordless SSH access, if not you can supply arguments to provide credentials `--ask-pass --ask-become-pass` to each command. - `server` and `agent` nodes should have passwordless SSH access, if not you can supply arguments to provide credentials `--ask-pass --ask-become-pass` to each command.
- You will also need to install collections that this playbook uses by running `ansible-galaxy collection install -r ./collections/requirements.yml` - You will also need to install collections that this playbook uses by running `ansible-galaxy install -r ./collections/requirements.yml`
## 🚀 Getting Started ## 🚀 Getting Started
+10 -21
View File
@@ -1,23 +1,12 @@
[defaults] [defaults]
nocows = True nocows = True
roles_path = ./roles roles_path = ./roles
inventory = ./hosts.ini inventory = ./hosts.ini
stdout_callback = yaml
remote_tmp = $HOME/.ansible/tmp remote_tmp = $HOME/.ansible/tmp
local_tmp = $HOME/.ansible/tmp local_tmp = $HOME/.ansible/tmp
timeout = 60 pipelining = True
host_key_checking = False become = True
deprecation_warnings = False host_key_checking = False
callback_whitelist = profile_tasks deprecation_warnings = False
log_path = ./ansible.log callback_whitelist = profile_tasks
[privilege_escalation]
become = True
[ssh_connection]
scp_if_ssh = smart
retries = 3
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o Compression=yes -o ServerAliveInterval=15s
pipelining = True
control_path = %(directory)s/%%h-%%r
+5 -10
View File
@@ -1,5 +1,5 @@
--- ---
k3s_version: v1.24.7+k3s1 k3s_version: v1.24.4+k3s1
# this is the user that has ssh access to these machines # this is the user that has ssh access to these machines
ansible_user: ansibleuser ansible_user: ansibleuser
systemd_dir: /etc/systemd/system systemd_dir: /etc/systemd/system
@@ -22,30 +22,25 @@ k3s_token: "some-SUPER-DEDEUPER-secret-password"
# it for each of your hosts, though. # it for each of your hosts, though.
k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}' k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}'
# Disable the taint manually by setting: k3s_master_taint = false
k3s_master_taint: "{{ true if groups['node'] | default([]) | length >= 1 else false }}"
# these arguments are recommended for servers as well as agents: # these arguments are recommended for servers as well as agents:
extra_args: >- extra_args: >-
--flannel-iface={{ flannel_iface }} --flannel-iface={{ flannel_iface }}
--node-ip={{ k3s_node_ip }} --node-ip={{ k3s_node_ip }}
# change these to your liking, the only required are: --disable servicelb, --tls-san {{ apiserver_endpoint }} # change these to your liking, the only required one is --disable servicelb
extra_server_args: >- extra_server_args: >-
{{ extra_args }} {{ extra_args }}
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
--tls-san {{ apiserver_endpoint }}
--disable servicelb --disable servicelb
--disable traefik --disable traefik
extra_agent_args: >- extra_agent_args: >-
{{ extra_args }} {{ extra_args }}
# image tag for kube-vip # image tag for kube-vip
kube_vip_tag_version: "v0.5.5" kube_vip_tag_version: "v0.5.0"
# image tag for metal lb # image tag for metal lb
metal_lb_speaker_tag_version: "v0.13.9" metal_lb_speaker_tag_version: "v0.13.5"
metal_lb_controller_tag_version: "v0.13.9" metal_lb_controller_tag_version: "v0.13.5"
# metallb ip range for load balancer # metallb ip range for load balancer
metal_lb_ip_range: "192.168.30.80-192.168.30.90" metal_lb_ip_range: "192.168.30.80-192.168.30.90"
+16 -42
View File
@@ -4,72 +4,46 @@ dependency:
driver: driver:
name: vagrant name: vagrant
platforms: platforms:
- &control
- name: control1 name: control1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 2048 memory: 2048
cpus: 2 cpus: 2
config_options:
# We currently can not use public-key based authentication on Ubuntu 22.04,
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
groups: groups:
- k3s_cluster - k3s_cluster
- master - master
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: 192.168.30.38 ip: 192.168.30.38
config_options: - <<: *control
# We currently can not use public-key based authentication on Ubuntu 22.04, name: control2
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
- name: control2
box: generic/debian11
memory: 2048
cpus: 2
groups:
- k3s_cluster
- master
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: 192.168.30.39 ip: 192.168.30.39
- <<: *control
- name: control3 name: control3
box: generic/rocky9
memory: 2048
cpus: 2
groups:
- k3s_cluster
- master
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: 192.168.30.40 ip: 192.168.30.40
- &node
- name: node1 <<: *control
box: generic/ubuntu2204 name: node1
memory: 2048
cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
- node - node
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: 192.168.30.41 ip: 192.168.30.41
config_options: - <<: *node
# We currently can not use public-key based authentication on Ubuntu 22.04, name: node2
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
- name: node2
box: generic/rocky9
memory: 2048
cpus: 2
groups:
- k3s_cluster
- node
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: 192.168.30.42 ip: 192.168.30.42
provisioner: provisioner:
name: ansible name: ansible
playbooks: playbooks:
-22
View File
@@ -1,22 +0,0 @@
---
- name: Apply overrides
ansible.builtin.import_playbook: >-
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
- name: Network setup
hosts: all
tasks:
- name: Disable firewalld
when: ansible_distribution == "Rocky"
# Rocky Linux comes with firewalld enabled. It blocks some of the network
# connections needed for our k3s cluster. For our test setup, we just disable
# it since the VM host's firewall is still active for connections to and from
# the Internet.
# When building your own cluster, please DO NOT blindly copy this. Instead,
# please create a custom firewall configuration that fits your network design
# and security needs.
ansible.builtin.systemd:
name: firewalld
enabled: no
state: stopped
become: true
+9 -17
View File
@@ -4,38 +4,30 @@ dependency:
driver: driver:
name: vagrant name: vagrant
platforms: platforms:
- &control
- name: control1 name: control1
box: generic/ubuntu2204 box: generic/ubuntu2204
memory: 2048 memory: 2048
cpus: 2 cpus: 2
config_options:
# We currently can not use public-key based authentication on Ubuntu 22.04,
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
groups: groups:
- k3s_cluster - k3s_cluster
- master - master
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: fdad:bad:ba55::de:11 ip: fdad:bad:ba55::de:11
config_options: - <<: *control
# We currently can not use public-key based authentication on Ubuntu 22.04, name: node1
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
- name: node1
box: generic/ubuntu2204
memory: 2048
cpus: 2
groups: groups:
- k3s_cluster - k3s_cluster
- node - node
interfaces: interfaces:
- network_name: private_network - network_name: private_network
ip: fdad:bad:ba55::de:21 ip: fdad:bad:ba55::de:21
config_options:
# We currently can not use public-key based authentication on Ubuntu 22.04,
# see: https://github.com/chef/bento/issues/1405
ssh.username: "vagrant"
ssh.password: "vagrant"
provisioner: provisioner:
name: ansible name: ansible
playbooks: playbooks:
-2
View File
@@ -36,8 +36,6 @@
# the default has IPv4 ranges only. # the default has IPv4 ranges only.
extra_server_args: >- extra_server_args: >-
{{ extra_args }} {{ extra_args }}
--tls-san {{ apiserver_endpoint }}
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
--disable servicelb --disable servicelb
--disable traefik --disable traefik
--disable-network-policy --disable-network-policy
@@ -3,12 +3,10 @@
run_once: true run_once: true
delegate_to: "{{ outside_host }}" delegate_to: "{{ outside_host }}"
block: block:
- name: "Test CASE: Get kube config" - ansible.builtin.import_tasks: kubecfg-fetch.yml
ansible.builtin.import_tasks: kubecfg-fetch.yml
- name: "TEST CASE: Get nodes" - name: "TEST CASE: Get nodes"
ansible.builtin.include_tasks: test/get-nodes.yml ansible.builtin.include_tasks: test/get-nodes.yml
- name: "TEST CASE: Deploy example" - name: "TEST CASE: Deploy example"
ansible.builtin.include_tasks: test/deploy-example.yml ansible.builtin.include_tasks: test/deploy-example.yml
always: always:
- name: "TEST CASE: Cleanup" - ansible.builtin.import_tasks: kubecfg-cleanup.yml
ansible.builtin.import_tasks: kubecfg-cleanup.yml
@@ -43,10 +43,6 @@
{{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }} {{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }}
port: >- port: >-
{{ nginx_services.resources[0].spec.ports[0].port }} {{ nginx_services.resources[0].spec.ports[0].port }}
# Deactivated linter rules:
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
# would be undefined. This will not be the case during playbook execution.
# noqa jinja[invalid]
always: always:
- name: "Remove namespace: {{ testing_namespace }}" - name: "Remove namespace: {{ testing_namespace }}"
@@ -22,7 +22,3 @@
| unique | unique
| sort | sort
}} }}
# Deactivated linter rules:
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
# would be undefined. This will not be the case during playbook execution.
# noqa jinja[invalid]
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
ansible-playbook reboot.yml -i inventory/my-cluster/hosts.ini
-9
View File
@@ -1,9 +0,0 @@
---
- name: Reboot k3s_cluster
hosts: k3s_cluster
gather_facts: yes
become: yes
tasks:
- name: Reboot the nodes (and Wait upto 5 mins max)
reboot:
reboot_timeout: 300
-13
View File
@@ -1,13 +0,0 @@
molecule>=4.0.3
ansible-core>=2.13.5
ansible-lint>=6.8.6
kubernetes>=25.3.0
molecule-vagrant>=1.0.0
molecule>=4.0.3
netaddr>=0.8.0
pyyaml>=6.0
yamllint>=1.28.0
jmespath>=1.0.1
jsonpatch>=1.32
pre-commit>=2.20.0
netaddr>=0.8.0
+8 -222
View File
@@ -1,222 +1,8 @@
# ansible-core>=2.13.2
# This file is autogenerated by pip-compile with python 3.8 jmespath
# To update, run: jsonpatch
# kubernetes>=12.0.0
# pip-compile requirements.in molecule-vagrant>=1.0.0
# molecule>=4.0.1
ansible-compat==2.2.4 netaddr>=0.8.0
# via pyyaml>=3.11
# ansible-lint
# molecule
ansible-core==2.13.5
# via
# -r requirements.in
# ansible-lint
ansible-lint==6.8.6
# via -r requirements.in
arrow==1.2.3
# via jinja2-time
attrs==22.1.0
# via jsonschema
binaryornot==0.4.4
# via cookiecutter
black==22.10.0
# via ansible-lint
bracex==2.3.post1
# via wcmatch
cachetools==5.2.0
# via google-auth
certifi==2022.9.24
# via
# kubernetes
# requests
cffi==1.15.1
# via cryptography
cfgv==3.3.1
# via pre-commit
chardet==5.0.0
# via binaryornot
charset-normalizer==2.1.1
# via requests
click==8.1.3
# via
# black
# click-help-colors
# cookiecutter
# molecule
click-help-colors==0.9.1
# via molecule
commonmark==0.9.1
# via rich
cookiecutter==2.1.1
# via molecule
cryptography==38.0.3
# via ansible-core
distlib==0.3.6
# via virtualenv
distro==1.8.0
# via selinux
enrich==1.2.7
# via molecule
filelock==3.8.0
# via
# ansible-lint
# virtualenv
google-auth==2.14.0
# via kubernetes
identify==2.5.8
# via pre-commit
idna==3.4
# via requests
importlib-resources==5.10.0
# via jsonschema
jinja2==3.1.2
# via
# ansible-core
# cookiecutter
# jinja2-time
# molecule
# molecule-vagrant
jinja2-time==0.2.0
# via cookiecutter
jmespath==1.0.1
# via -r requirements.in
jsonpatch==1.32
# via -r requirements.in
jsonpointer==2.3
# via jsonpatch
jsonschema==4.17.0
# via
# ansible-compat
# ansible-lint
# molecule
kubernetes==25.3.0
# via -r requirements.in
markupsafe==2.1.1
# via jinja2
molecule==4.0.3
# via
# -r requirements.in
# molecule-vagrant
molecule-vagrant==1.0.0
# via -r requirements.in
mypy-extensions==0.4.3
# via black
netaddr==0.8.0
# via -r requirements.in
nodeenv==1.7.0
# via pre-commit
oauthlib==3.2.2
# via requests-oauthlib
packaging==21.3
# via
# ansible-compat
# ansible-core
# ansible-lint
# molecule
pathspec==0.10.1
# via
# black
# yamllint
pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==2.5.2
# via
# black
# virtualenv
pluggy==1.0.0
# via molecule
pre-commit==2.20.0
# via -r requirements.in
pyasn1==0.4.8
# via
# pyasn1-modules
# rsa
pyasn1-modules==0.2.8
# via google-auth
pycparser==2.21
# via cffi
pygments==2.13.0
# via rich
pyparsing==3.0.9
# via packaging
pyrsistent==0.19.2
# via jsonschema
python-dateutil==2.8.2
# via
# arrow
# kubernetes
python-slugify==6.1.2
# via cookiecutter
python-vagrant==1.0.0
# via molecule-vagrant
pyyaml==6.0
# via
# -r requirements.in
# ansible-compat
# ansible-core
# ansible-lint
# cookiecutter
# kubernetes
# molecule
# molecule-vagrant
# pre-commit
# yamllint
requests==2.28.1
# via
# cookiecutter
# kubernetes
# requests-oauthlib
requests-oauthlib==1.3.1
# via kubernetes
resolvelib==0.8.1
# via ansible-core
rich==12.6.0
# via
# ansible-lint
# enrich
# molecule
rsa==4.9
# via google-auth
ruamel-yaml==0.17.21
# via ansible-lint
ruamel-yaml-clib==0.2.7
# via ruamel-yaml
selinux==0.2.1
# via molecule-vagrant
six==1.16.0
# via
# google-auth
# kubernetes
# python-dateutil
subprocess-tee==0.3.5
# via ansible-compat
text-unidecode==1.3
# via python-slugify
toml==0.10.2
# via pre-commit
tomli==2.0.1
# via black
typing-extensions==4.4.0
# via
# black
# rich
urllib3==1.26.12
# via
# kubernetes
# requests
virtualenv==20.16.6
# via pre-commit
wcmatch==8.4.1
# via ansible-lint
websocket-client==1.4.2
# via kubernetes
yamllint==1.28.0
# via
# -r requirements.in
# ansible-lint
zipp==3.10.0
# via importlib-resources
# The following packages are considered to be unsafe in a requirements file:
# setuptools
-6
View File
@@ -5,9 +5,3 @@
become: yes become: yes
roles: roles:
- role: reset - role: reset
- role: raspberrypi
vars: {state: absent}
post_tasks:
- name: Reboot and wait for node to come back up
reboot:
reboot_timeout: 3600
+2 -9
View File
@@ -152,19 +152,12 @@
owner: "{{ ansible_user }}" owner: "{{ ansible_user }}"
mode: "u=rw,g=,o=" mode: "u=rw,g=,o="
- name: Configure kubectl cluster to {{ endpoint_url }} - name: Configure kubectl cluster to https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
command: >- command: >-
k3s kubectl config set-cluster default k3s kubectl config set-cluster default
--server={{ endpoint_url }} --server=https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
--kubeconfig ~{{ ansible_user }}/.kube/config --kubeconfig ~{{ ansible_user }}/.kube/config
changed_when: true changed_when: true
vars:
endpoint_url: >-
https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
# Deactivated linter rules:
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
# would be undefined. This will not be the case during playbook execution.
# noqa jinja[invalid]
- name: Create kubectl symlink - name: Create kubectl symlink
file: file:
+1 -1
View File
@@ -1,3 +1,3 @@
--- ---
# Timeout to wait for MetalLB services to come up # Timeout to wait for MetalLB services to come up
metal_lb_available_timeout: 120s metal_lb_available_timeout: 60s
+3 -3
View File
@@ -28,9 +28,9 @@
command: >- command: >-
k3s kubectl wait {{ item.resource }} k3s kubectl wait {{ item.resource }}
--namespace='metallb-system' --namespace='metallb-system'
{% if item.name | default(False) -%}{{ item.name }}{%- endif %} {% if item.name | default(False) -%} {{ item.name }} {%- endif %}
{% if item.selector | default(False) -%}--selector='{{ item.selector }}'{%- endif %} {% if item.selector | default(False) -%} --selector='{{ item.selector }}' {%- endif %}
{% if item.condition | default(False) -%}{{ item.condition }}{%- endif %} {% if item.condition | default(False) -%} {{ item.condition }} {%- endif %}
--timeout='{{ metal_lb_available_timeout }}' --timeout='{{ metal_lb_available_timeout }}'
changed_when: false changed_when: false
run_once: true run_once: true
-6
View File
@@ -1,6 +0,0 @@
---
# Indicates whether the k3s prerequisites for Raspberry Pi should be set up
# Possible values:
# - present
# - absent
state: present
+6 -13
View File
@@ -47,20 +47,13 @@
- raspberry_pi|default(false) - raspberry_pi|default(false)
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye") - ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
- name: execute OS related tasks on the Raspberry Pi - {{ action }} - name: execute OS related tasks on the Raspberry Pi
include_tasks: "{{ item }}" include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "{{ action }}/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml" - "prereq/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
- "{{ action }}/{{ detected_distribution }}.yml" - "prereq/{{ detected_distribution }}.yml"
- "{{ action }}/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" - "prereq/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ action }}/{{ ansible_distribution }}.yml" - "prereq/{{ ansible_distribution }}.yml"
- "{{ action }}/default.yml" - "prereq/default.yml"
vars:
action: >-
{% if state == "present" -%}
setup
{%- else -%}
teardown
{%- endif %}
when: when:
- raspberry_pi|default(false) - raspberry_pi|default(false)
@@ -1,5 +1,5 @@
--- ---
- name: Enable cgroup via boot commandline if not already enabled for Rocky - name: Enable cgroup via boot commandline if not already enabled for Centos
lineinfile: lineinfile:
path: /boot/cmdline.txt path: /boot/cmdline.txt
backrefs: yes backrefs: yes
@@ -6,8 +6,8 @@
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
notify: reboot notify: reboot
when: not ansible_check_mode
- name: Install linux-modules-extra-raspi - name: Install linux-modules-extra-raspi
apt: apt: name=linux-modules-extra-raspi state=present
name: linux-modules-extra-raspi when: (raspberry_pi) and (not ansible_check_mode)
state: present
@@ -1 +0,0 @@
---
@@ -1 +0,0 @@
---
@@ -1,5 +0,0 @@
---
- name: Remove linux-modules-extra-raspi
apt:
name: linux-modules-extra-raspi
state: absent
@@ -1 +0,0 @@
---
+8 -1
View File
@@ -50,7 +50,14 @@
systemd: systemd:
daemon_reload: yes daemon_reload: yes
- name: Remove tmp directory used for manifests - name: Remove linux-modules-extra-raspi
apt: name=linux-modules-extra-raspi state=absent
- name: Remove tmp director used for manifests
file: file:
path: /tmp/k3s path: /tmp/k3s
state: absent state: absent
- name: Reboot and wait for node to come back up
reboot:
reboot_timeout: 3600