Skip to content

Commit

Permalink
Rename role
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak committed Dec 6, 2023
1 parent fa2060a commit 3dc0c34
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
defaults:

run:
working-directory: 'nephelaiio.kubectl'
working-directory: 'nephelaiio.k8s_repo'

jobs:

Expand All @@ -22,7 +22,7 @@ jobs:
- name: Check out the codebase
uses: actions/checkout@v4
with:
path: 'nephelaiio.kubectl'
path: 'nephelaiio.k8s_repo'

- name: Set up python 3
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
defaults:

run:
working-directory: 'nephelaiio.kubectl'
working-directory: 'nephelaiio.k8s_repo'

jobs:

Expand All @@ -37,7 +37,7 @@ jobs:
- name: Check out the codebase
uses: actions/checkout@v4
with:
path: 'nephelaiio.kubectl'
path: 'nephelaiio.k8s_repo'

- name: Set up python 3
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
defaults:

run:
working-directory: 'nephelaiio.kubectl'
working-directory: 'nephelaiio.k8s_repo'

jobs:

Expand All @@ -26,7 +26,7 @@ jobs:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
path: 'nephelaiio.kubectl'
path: 'nephelaiio.k8s_repo'

- name: Set up Python 3
uses: actions/setup-python@v4
Expand Down
2 changes: 2 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fileignoreconfig:
- filename: poetry.lock
ignore_detectors: [filecontent]
- filename: defaults/main.yml
ignore_detectors: [filecontent]
- filename: .github/workflows/release.yml
ignore_detectors: [filecontent]
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# nephelaiio.kubectl
# nephelaiio.k8s_repo

[![Build Status](https://github.com/nephelaiio/ansible-role-kubectl/actions/workflows/molecule.yml/badge.svg)](https://github.com/nephelaiio/ansible-role-kubectl/actions/wofklows/molecule.yml)
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-nephelaiio.kubectl.vim-blue.svg)](https://galaxy.ansible.com/nephelaiio/kubectl/)
[![Build Status](https://github.com/nephelaiio/ansible-role-k8s-repo/actions/workflows/molecule.yml/badge.svg)](https://github.com/nephelaiio/ansible-role-k8s-repo/actions/wofklows/molecule.yml)
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-nephelaiio.k8s-repo.vim-blue.svg)](https://galaxy.ansible.com/nephelaiio/k8s-repo/)

<!--
[![Ansible Galaxy](https://img.shields.io/badge/dynamic/json?color=blueviolet&label=nephelaiio/kubectl&query=%24.summary_fields.versions%5B0%5D.name&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F<galaxy_id>%2F%3Fformat%3Djson)](https://galaxy.ansible.com/nephelaiio/kubectl/)
-->

An [ansible role](https://galaxy.ansible.com/nephelaiio/kubectl) to install and configure kubectl
An [ansible role](https://galaxy.ansible.com/nephelaiio/k8s-repo) to install and configure Kubernetes package repostiories

## Role Variables

Expand All @@ -21,19 +17,18 @@ By default this role does not depend on any external roles. If any such dependen

- hosts: servers
roles:
- role: nephelaiio.kubectl
kubectl_package_state: latest
- role: nephelaiio.k8s_repo

## Testing

Please make sure your environment has [docker](https://www.docker.com) installed in order to run role validation tests. Additional python dependencies are listed in the [requirements file](https://github.com/nephelaiio/ansible-role-requirements/blob/master/requirements.txt)

Role is tested against the following distributions (docker images):

* Ubuntu Focal
* Ubuntu Jammy
* Debian Buster
* Ubuntu Focal
* Debian Bullseye
* Debian Bookworm

You can test the role directly from sources using command ` molecule test `

Expand Down
5 changes: 3 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# kubectl_release: v1.28
kubectl_state: present
# k8s_repo_release: v1.28
k8s_repo_state: latest
k8s_repo_keyring_debian: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
6 changes: 3 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---

Check failure on line 1 in meta/main.yml

View workflow job for this annotation

GitHub Actions / lint

meta-no-tags

Tags must contain lowercase letters and digits only., invalid: 'k8s_repo'

Check failure on line 1 in meta/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, ubuntu2004, /lib/systemd/systemd)

meta-no-tags

Tags must contain lowercase letters and digits only., invalid: 'k8s_repo'

Check failure on line 1 in meta/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, debian11, /lib/systemd/systemd)

meta-no-tags

Tags must contain lowercase letters and digits only., invalid: 'k8s_repo'

Check failure on line 1 in meta/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, centos8, /usr/lib/systemd/systemd)

meta-no-tags

Tags must contain lowercase letters and digits only., invalid: 'k8s_repo'
galaxy_info:
role_name: kubectl
role_name: k8s_repo
author: nephelaiio
description: An Ansible role to install and configure kubectl
description: An Ansible role to configure K8s package repositories
license: MIT
min_ansible_version: '2.15'
platforms:
Expand All @@ -15,6 +15,6 @@ galaxy_info:
- name: Debian
versions:
- all
galaxy_tags: ['kubectl']
galaxy_tags: ['k8s', 'k8s_repo', 'repo', 'repository']

dependencies: []
7 changes: 2 additions & 5 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
- name: Converge

hosts: all

become: true
roles:

- nephelaiio.plugins
- nephelaiio.kubectl
- nephelaiio.k8s_repo
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependency:
driver:
name: docker
platforms:
- name: kubectl-install-01
- name: k8s-repo-install-01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
5 changes: 0 additions & 5 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
---
- name: Prepare

hosts: all

gather_facts: true

become: true

tasks:

- name: Update apt package cache
ansible.builtin.apt:
update_cache: yes
Expand Down
4 changes: 0 additions & 4 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
---
- name: Verify

hosts: all

gather_facts: true

become: true

tasks:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "nephelaiio.kubectl"
name = "nephelaiio.k8s_repo"
version = "0.1.0"
description = ""
authors = ["nephelaiio"]
Expand Down
44 changes: 37 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
---
- name: Set kubectl install target release
- name: Set Kubernetes repository version
ansible.builtin.set_fact:
kubectl_version: "{{ lookup('ansible.builtin.url', 'https://dl.k8s.io/release/stable.txt', split_lines=False) }}"
when: kubectl_version is not defined
k8s_repo_version: "{{ lookup('ansible.builtin.url', 'https://dl.k8s.io/release/stable.txt', split_lines=False) }}"
when: k8s_repo_version is not defined

- name: Set kubectl release facts
- name: Set Kuberentes repository release facts
ansible.builtin.set_fact:
_kubectl_target: "{{ '.'.join(kubectl_version.split('.')[0:2]) }}"
_k8s_repo_target: "{{ '.'.join(k8s_repo_version.split('.')[0:2]) }}"

- name: Deploy on Debian systems
- name: Configure Kubernetes apt repository
when: ansible_os_family == "Debian"
block:
- name: Create tempfile
ansible.builtin.tempfile:
suffix: k8s

- name: Set distribution facts
ansible.builtin.set_fact:
_apt_repo_url: "https://pkgs.k8s.io/core:/stable:/{{ _k8s_repo_target }}/deb"

- name: Install Debian package helpers
ansible.builtin.package:
name:
- apt-transport-https
- ca-certificates
- curl

- name: Create keyring directory
ansible.builtin.file:
path: "{{ k8s_repo_keyring_debian | dirname }}"
state: directory
owner: root
group: root
mode: 0755

- name: Install gpg certificate

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / lint

command-instead-of-module

curl used in place of get_url or uri module

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / lint

risky-shell-pipe

Shells that use pipes should set the pipefail option.

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, ubuntu2004, /lib/systemd/systemd)

command-instead-of-module

curl used in place of get_url or uri module

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, ubuntu2004, /lib/systemd/systemd)

risky-shell-pipe

Shells that use pipes should set the pipefail option.

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, debian11, /lib/systemd/systemd)

command-instead-of-module

curl used in place of get_url or uri module

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, debian11, /lib/systemd/systemd)

risky-shell-pipe

Shells that use pipes should set the pipefail option.

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, centos8, /usr/lib/systemd/systemd)

command-instead-of-module

curl used in place of get_url or uri module

Check failure on line 37 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, centos8, /usr/lib/systemd/systemd)

risky-shell-pipe

Shells that use pipes should set the pipefail option.
ansible.builtin.shell:
cmd: >-
curl -fsSL {{ _apt_repo_url }}/Release.key | gpg --dearmor -o {{ k8s_repo_keyring_debian }}
executable: /bin/bash
changed_when: false

- name: Configure apt repository
ansible.builtin.apt_repository:
filename: k8s_repo
repo: "deb [signed-by={{ k8s_repo_keyring_debian }}] {{ _apt_repo_url }} /"

- name: Deploy on RedHat systems
- name: Configure Kubernetes yum repository
when: ansible_os_family == "RedHat"
block:
- fail:

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / lint

fqcn[action-core]

Use FQCN for builtin module actions (fail).

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / lint

name[missing]

All tasks should be named.

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, ubuntu2004, /lib/systemd/systemd)

fqcn[action-core]

Use FQCN for builtin module actions (fail).

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, ubuntu2004, /lib/systemd/systemd)

name[missing]

All tasks should be named.

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, debian11, /lib/systemd/systemd)

fqcn[action-core]

Use FQCN for builtin module actions (fail).

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, debian11, /lib/systemd/systemd)

name[missing]

All tasks should be named.

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, centos8, /usr/lib/systemd/systemd)

fqcn[action-core]

Use FQCN for builtin module actions (fail).

Check failure on line 52 in tasks/main.yml

View workflow job for this annotation

GitHub Actions / molecule (default, centos8, /usr/lib/systemd/systemd)

name[missing]

All tasks should be named.

0 comments on commit 3dc0c34

Please sign in to comment.