Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lint warnings #33

Merged
merged 9 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: molecule

on:
pull_request:
push:
branches:
- master
schedule:
- cron: "0 5 * * 5"

Expand Down
6 changes: 6 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ fileignoreconfig:
ignore_detectors: [ filename ]
- filename: tasks/verify/mysql.yml
ignore_detectors: [ filename ]
- filename: tasks/verify/argocd.yml
ignore_detectors: [ filecontent ]
- filename: tasks/verify/install.yml
ignore_detectors: [ filecontent ]
- filename: tasks/verify/secrets.yml
ignore_detectors: [ filecontent ]
- filename: .github/workflows/release.yml
ignore_detectors: [ filecontent ]
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
##
# nephelaiio.k8s Ansible role
#
# @file
# @version 0.0.1

.PHONY: all ${MAKECMDGOALS}

KIND_RELEASE := $$(yq eval '.jobs.molecule.strategy.matrix.include[0].release ' .github/workflows/molecule.yml)
Expand Down Expand Up @@ -65,5 +59,3 @@ poetry: install

%:
@:

# end
2 changes: 1 addition & 1 deletion defaults/main/k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ k8s_address_pools_aws:
- scheme: 'internet-facing'
name: public
k8s_retry_delay: 30
k8s_retry_num: 6
k8s_retry_num: 10

k8s_address_pool_private_name: "private"
k8s_address_pool_private_iprange: ""
Expand Down
14 changes: 2 additions & 12 deletions molecule/argocd/side_effect.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
---
- name: Verify

hosts: all

gather_facts: false

vars:

k8s_argocd_exec_timeout: 2m

roles:

- nephelaiio.plugins

tasks:

- name: mutate and verify cluster
include_role:
- name: Mutate and verify cluster
ansible.builtin.include_role:
name: nephelaiio.k8s
vars:
k8s_deploy: true
Expand Down
12 changes: 2 additions & 10 deletions molecule/common/converge.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
---
- name: Converge

hosts: localhost

gather_facts: false

roles:

- nephelaiio.plugins

tasks:

- name: deploy cluster
include_role:
- name: Deploy cluster
ansible.builtin.include_role:
name: nephelaiio.k8s
vars:
k8s_deploy: true
Expand Down
31 changes: 11 additions & 20 deletions molecule/common/create.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
---
- name: Create

hosts: localhost

roles:

- nephelaiio.plugins

tasks:

- name: deploy kind cluster
- name: Deploy kind cluster
when: k8s_molecule_cluster_type == 'kind'
block:

- name: deploy kind cluster
- name: Deploy kind cluster
ansible.builtin.include_role:
name: nephelaiio.kind
vars:
kind_image_tag: "{{ lookup('ansible.builtin.env', 'K8S_RELEASE') | default('v1.24.4') }}"

when: k8s_molecule_cluster_type == 'kind'

- name: deploy k3s cluster
- name: Deploy k3s cluster
when: k8s_molecule_cluster_type == 'k3s'
block:

- name: create k3s tempdir
- name: Create k3s tempdir
ansible.builtin.tempfile:
state: directory
prefix: "k3s_"
register: tempdir

- name: retrieve k3s installer
- name: Retrieve k3s installer
ansible.builtin.get_url:
url: https://get.k3s.io
dest: "{{ tempdir.path }}/k3s"
mode: 0755

- name: deploy k3s cluster
- name: Deploy k3s cluster
ansible.builtin.command: "{{ tempdir.path }}/k3s --disable=traefik"
vars:
k3s_version: "{{ lookup('ansible.builtin.env', 'K8S_RELEASE') }}+k3s1"
environment:
INSTALL_K3S_VERSION: "{{ k3s_version }}"
become: true

- name: install iscsi tools
- name: Install iscsi tools
ansible.builtin.package:
name: open-iscsi
retries: 3
Expand All @@ -52,7 +45,7 @@
until: package_install is succeeded
become: yes

- name: copy k3s kubeconfig
- name: Copy k3s kubeconfig
ansible.builtin.copy:
src: "/etc/rancher/k3s/k3s.yaml"
dest: "{{ k8s_kubeconfig }}"
Expand All @@ -64,9 +57,7 @@
ansible_user: "{{ lookup('ansible.builtin.env', 'USER') }}"
become: true

- name: remove k3s tempdir
- name: Remove k3s tempdir
ansible.builtin.file:
path: "{{ tempdir.path }}"
state: absent

when: k8s_molecule_cluster_type == 'k3s'
24 changes: 8 additions & 16 deletions molecule/common/destroy.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
---
- name: Destroy

hosts: localhost

gather_facts: true

tasks:

- name: destroy kind cluster
- name: Destroy kind cluster
when: k8s_molecule_cluster_type == 'kind'
block:

- name: destroy kind cluster
- name: Destroy kind cluster
ansible.builtin.include_role:
name: nephelaiio.kind
vars:
kind_state: absent
kind_cluster_state: absent
kind_image_tag: "{{ lookup('ansible.builtin.env', 'K8S_RELEASE') }}"

when: k8s_molecule_cluster_type == 'kind'

- name: destroy k3s cluster
- name: Destroy k3s cluster
when: k8s_molecule_cluster_type == 'k3s'
block:

- name: stat mysql router state file
- name: Stat mysql router state file
ansible.builtin.stat:
path: "/usr/local/bin/k3s-uninstall.sh"
register: k8s_uninstaller

- name: destroy k3s cluster
- name: Destroy k3s cluster
ansible.builtin.command: "{{ k8s_uninstaller.stat.path }}"
when: k8s_uninstaller.stat.exists
become: true

when: k8s_molecule_cluster_type == 'k3s'

- name: delete certificate from edge truststore
- name: Delete certificate from edge truststore
ansible.builtin.command: "certutil -d sql:$HOME/.pki/nssdb -D -n {{ k8s_cluster_name }}"
changed_when: false
ignore_errors: true
29 changes: 11 additions & 18 deletions molecule/common/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
---
- name: Prepare

hosts: localhost

gather_facts: false

tasks:

- name: check local helm binary
- name: Check local helm binary
ansible.builtin.shell: "which {{ lookup('ansible.builtin.env', 'HELM_BIN', default='helm') }}"
register: helm_bin_query
changed_when: false

- name: copy helm binary
- name: Copy helm binary
ansible.builtin.copy:
src: "{{ helm_bin_query.stdout }}"
dest: "{{ k8s_helm_bin }}"
mode: '0755'
when: helm_bin_query is succeeded

- name: download helm binary
- name: Download helm binary
when: helm_bin_query is not succeeded
block:

- name: query helm releases
- name: Query helm releases
ansible.builtin.uri:
url: https://api.github.com/repos/helm/helm/releases/latest
register: helm_release_query

- name: set kind release target
- name: Set kind release target
ansible.builtin.set_fact:
helm_release: "{{ helm_release_query.json.tag_name }}"

- name: create temporary directory
- name: Create temporary directory
ansible.builtin.tempfile:
state: directory
prefix: kind
register: _tmpdir
changed_when: false

- name: install helm binary
- name: Install helm binary
block:

- name: download helm release package
- name: Download helm release package
ansible.builtin.unarchive:
src: "https://get.helm.sh/helm-{{ helm_release }}-linux-amd64.tar.gz"
dest: "{{ _tmpdir.path }}"
Expand All @@ -53,7 +47,7 @@
until: helm_dl_op is success
changed_when: false

- name: find helm executable
- name: Find helm executable
ansible.builtin.find:
paths: "{{ _tmpdir.path }}"
file_type: file
Expand All @@ -63,15 +57,14 @@
- '^helm$'
register: helm_bin

- name: copy helm copy helm binary
- name: Copy helm copy helm binary
ansible.builtin.copy:
src: "{{ helm_bin.files[0].path }}"
dest: "{{ k8s_helm_bin }}"
mode: '0755'

always:

- name: cleanup temp files
- name: Cleanup temp files
ansible.builtin.file:
state: absent
path: "{{ _tmpdir.path }}"
12 changes: 2 additions & 10 deletions molecule/common/verify.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
---
- name: Verify

hosts: localhost

gather_facts: false

roles:

- nephelaiio.plugins

tasks:

- name: verify cluster
include_role:
- name: Verify cluster
ansible.builtin.include_role:
name: nephelaiio.k8s
vars:
k8s_deploy: false
Expand Down
21 changes: 9 additions & 12 deletions tasks/deploy/argocd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
- name: Set deployment facts
ansible.builtin.set_fact:
_query: 'kubernetes.core.k8s'
_ns: "{{ k8s_argocd_namespace }}"
_config: "{{ k8s_kubeconfig }}"
_resource: 'argocd-repo-server'

- name: Install argocd chart
kubernetes.core.helm:
name: argocd
Expand All @@ -18,12 +25,7 @@
ansible.builtin.set_fact:
_reposerver_def: "{{ _reposerver_query | first }}"
vars:
_reposerver_query: "{{ query(
'kubernetes.core.k8s',
kind='Deployment',
namespace=k8s_argocd_namespace,
resource_name='argocd-repo-server',
kubeconfig=k8s_kubeconfig) }}"
_reposerver_query: "{{ query(_query, kind='Deployment', namespace=_ns, resource_name=_resource, kubeconfig=_config) }}"

- name: Patch argocd reposerver deployment
kubernetes.core.k8s_json_patch:
Expand All @@ -43,12 +45,7 @@
_reposerver_env_pre: "{{ _reposerver_env_def | rejectattr('name', 'equalto', _reposerver_env_timeout.name) }}"
_reposerver_env_new: "{{ _reposerver_env_pre + [_reposerver_env_timeout] }}"
_reposerver_def: "{{ _reposerver_query | first }}"
_reposerver_query: "{{ query(
'kubernetes.core.k8s',
kind='Deployment',
namespace=k8s_argocd_namespace,
resource_name='argocd-repo-server',
kubeconfig=k8s_kubeconfig) }}"
_reposerver_query: "{{ query(_query, kind='Deployment', namespace=_ns, resource_name=_resource, kubeconfig=_config) }}"
changed_when: false

- name: Deploy argocd ingress
Expand Down
2 changes: 1 addition & 1 deletion tasks/deploy/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
msg: "k8s_nginx_chart_release must be at least '{{ chart_release_min }}'"
vars:
chart_release_min: "4.0.15"
chart_release_req_normalized: "{{ k8s_nginx_chart.release | regex_replace('^v' ,'') }}"
chart_release_req_normalized: "{{ k8s_nginx_chart.release | regex_replace('^v', '') }}"
chart_release_min_normalized: "{{ chart_release_min | regex_replace('^v', '') }}"
when: (chart_release_req_normalized) is version(chart_release_min_normalized, operator='lt')

Expand Down
2 changes: 0 additions & 2 deletions tasks/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

- name: Include verification checks
block:

- name: Include secret checks
ansible.builtin.include_tasks: verify/secrets.yml
when: k8s_secrets | length > 0
Expand Down Expand Up @@ -73,7 +72,6 @@
ansible.builtin.include_tasks: verify/cmds.yml

always:

- name: Cleanup temp files
ansible.builtin.file:
state: absent
Expand Down
Loading
Loading