Skip to content

Commit

Permalink
In the begginning there was darkness
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak committed Aug 25, 2022
0 parents commit 1c4d55c
Show file tree
Hide file tree
Showing 23 changed files with 2,144 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
skip_list:
- '106'
- '208'
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = .venv/,.tox/,dist/,build/,doc/,.eggs/,molecule/provisioner/ansible/plugins/libraries/goss.py
format = pylint
19 changes: 19 additions & 0 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: CI Keepalive

on:
schedule:
- cron: "55 23 * * 4"

jobs:
keepalive:
name: Github Actions keepalive
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gautamkrishnar/keepalive-workflow@master
with:
commit_message: "CI Keepalive"
committer_username: "Ted Cook"
committer_email: "Ted [email protected]"
auto_push: true
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: Molecule

on:

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

defaults:

run:
working-directory: 'nephelaiio.k8s'

jobs:

lint:

name: lint
runs-on: ubuntu-latest
steps:

- name: check out the codebase
uses: actions/checkout@v2
with:
path: 'nephelaiio.k8s'

- name: set up python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: install poetry
run: pip3 install poetry

- name: install pips
run: poetry install

- name: lint code
run: |
set -e
poetry run yamllint .
poetry ansible-lint .
molecule:

name: molecule
runs-on: ubuntu-latest
strategy:
matrix:
image:
- ubuntu2204
- ubuntu2004
- debian11
- debian10
- centos7
steps:
- name: check out the codebase.
uses: actions/checkout@v2
with:
path: 'nephelaiio.k8s'

- name: set up python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: install poetry
run: pip3 install poetry

- name: install pips
run: poetry install

- name: run molecule tests.
run: poetry run molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DOCKER_IMAGE: ${{ matrix.image }}
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
# repository or organization.
#
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
# See: https://github.com/ansible/galaxy/issues/46

name: Release
on:
push:
tags:
- "*"

defaults:

run:
working-directory: 'nephelaiio.k8s'

jobs:

release:

name: Release
runs-on: ubuntu-latest
steps:
- name: check out the codebase.
uses: actions/checkout@v2
with:
path: 'nephelaiio.k8s'

- name: set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: install poetry
run: pip3 install poetry

- name: install pips
run: poetry install

- name: trigger a new import on galaxy
run: >-
poetry run ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo $GITHUB_REPOSITORY | cut -d/ -f1) $(echo $GITHUB_REPOSITORY | cut -d/ -f2)
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.swp
.molecule/
.cache/
__pycache__/
Gemfile.lock
**/.ropeproject
playbook.retry
12 changes: 12 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (c) 2022 Ted Cook


Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# nephelaiio.k8s

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

An [ansible role](https://galaxy.ansible.com/nephelaiio/k8s) to install and configure k8s

## Role Variables

Please refer to the [defaults file](/defaults/main.yml) for an up to date list of input parameters.

## Dependencies

By default this role does not depend on any external roles. If any such dependency is required please [add them](/meta/main.yml) according to [the documentation](http://docs.ansible.com/ansible/playbooks_roles.html#role-dependencies)

## Example Playbook

- hosts: servers
roles:
- role: nephelaiio.k8s
k8s_package_state: latest

## 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 Bionic
* Ubuntu Xenial
* CentOS 7
* Debian Buster

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

## License

This project is licensed under the terms of the [MIT License](/LICENSE)
19 changes: 19 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
k8s_deployment_prefix: "nephelaiio_"

k8s_argocd_namespace: argocd
k8s_argocd_state: present
k8s_argocd_chart_url: https://argoproj.github.io/argo-helm
k8s_argocd_chart_release: 4.10.9
k8s_argocd_chart_customize: true
k8s_argocd_chart_values:
redis-ha:
enabled: true
controller:
replicas: 1
server:
replicas: 2
repoServer:
replicas: 2
applicationSet:
replicas: 2
1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
22 changes: 22 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
galaxy_info:
role_name: k8s
namespace: nephelaiio
author: nephelaiio
description: Ansible role to bootstrap k8s cluster deployment
license: MIT
min_ansible_version: 2.8
platforms:
- name: EL
versions:
- all
- name: Ubuntu
versions:
- all
- name: Debian
versions:
- all
galaxy_tags: ['k8s']

dependencies:
- nephelaiio.plugins
46 changes: 46 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
*******
Install
*******

This set of playbooks have specific dependencies on Ansible due to the modules
being used.

Requirements
============

* Ansible 2.2
* Docker Engine
* docker-py

Install OS dependencies on CentOS 7

.. code-block:: bash
$ sudo yum install -y epel-release
$ sudo yum install -y gcc python-pip python-devel openssl-devel
# If installing Molecule from source.
$ sudo yum install libffi-devel git
Install OS dependencies on Ubuntu 16.x

.. code-block:: bash
$ sudo apt-get update
$ sudo apt-get install -y python-pip libssl-dev docker-engine
# If installing Molecule from source.
$ sudo apt-get install -y libffi-dev git
Install OS dependencies on Mac OS

.. code-block:: bash
$ brew install python
$ brew install git
Install using pip:

.. code-block:: bash
$ sudo pip install ansible
$ sudo pip install docker-py
$ sudo pip install molecule --pre
13 changes: 13 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: converge

hosts: localhost

vars:

k8s_kubeconfig: "/tmp/config.kind.molecule"

roles:

- nephelaiio.plugins
- nephelaiio.k8s
58 changes: 58 additions & 0 deletions molecule/default/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- name: destroy

hosts: localhost

connection: local

gather_facts: true

vars:

k8s_kubeconfig: "/tmp/config.kind.molecule"

tasks:

- block:

- name: create temporary directory
local_action:
module: ansible.builtin.tempfile
state: directory
prefix: kind
register: tmpdir
changed_when: false

- block:

- name: query kind releases
ansible.builtin.uri:
url: https://api.github.com/repos/kubernetes-sigs/kind/releases/latest
register: kind_release_query

- name: set kind release target
ansible.builtin.set_fact:
kind_release: "{{ kind_release_query.json.name }}"

when: kind_release is not defined

- name: download kind executable
ansible.builtin.get_url:
url: "https://kind.sigs.k8s.io/dl/{{ kind_release.tag }}/kind-{{ ansible_system }}-amd64"
dest: "{{ tmpdir.path }}/kind"
mode: 0777
changed_when: false

- name: deploy kind cluster
ansible.builtin.shell: >-
{{ _bin }} get clusters | grep molecule &&
{{ _bin }} delete cluster --name molecule
vars:
_bin: "{{ tmpdir.path }}/kind"

always:

- name: cleanup temp files
ansible.builtin.file:
state: absent
path: "{{ tmpdir.path }}"
Loading

0 comments on commit 1c4d55c

Please sign in to comment.