diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..12851a05a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "ansible-dev-container-codespaces", + "image": "ghcr.io/ansible/community-ansible-dev-tools:latest", + "containerUser": "root", + "runArgs": [ + "--security-opt", + "seccomp=unconfined", + "--security-opt", + "label=disable", + "--cap-add=SYS_ADMIN", + "--cap-add=SYS_RESOURCE", + "--device", + "/dev/fuse", + "--security-opt", + "apparmor=unconfined", + "--hostname=ansible-dev-container" + ], + "updateRemoteUserUID": true, + "customizations": { + "vscode": { + "extensions": ["redhat.ansible", "redhat.vscode-redhat-account"] + } + } +} diff --git a/.devcontainer/docker/devcontainer.json b/.devcontainer/docker/devcontainer.json new file mode 100644 index 000000000..98ddc1517 --- /dev/null +++ b/.devcontainer/docker/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "ansible-dev-container-docker", + "image": "ghcr.io/ansible/community-ansible-dev-tools:latest", + "containerUser": "root", + "runArgs": [ + "--security-opt", + "seccomp=unconfined", + "--security-opt", + "label=disable", + "--cap-add=SYS_ADMIN", + "--cap-add=SYS_RESOURCE", + "--device", + "/dev/fuse", + "--security-opt", + "apparmor=unconfined", + "--hostname=ansible-dev-container" + ], + "updateRemoteUserUID": true, + "customizations": { + "vscode": { + "extensions": ["redhat.ansible", "redhat.vscode-redhat-account"] + } + } +} diff --git a/.devcontainer/podman/devcontainer.json b/.devcontainer/podman/devcontainer.json new file mode 100644 index 000000000..a11a3dfcd --- /dev/null +++ b/.devcontainer/podman/devcontainer.json @@ -0,0 +1,26 @@ +{ + "name": "ansible-dev-container-podman", + "image": "ghcr.io/ansible/community-ansible-dev-tools:latest", + "containerUser": "root", + "runArgs": [ + "--cap-add=SYS_ADMIN", + "--cap-add=SYS_RESOURCE", + "--device", + "/dev/fuse", + "--security-opt", + "seccomp=unconfined", + "--security-opt", + "label=disable", + "--security-opt", + "apparmor=unconfined", + "--userns=host", + "--hostname=ansible-dev-container", + "--volume", + "ansible-dev-tools-container-storage:/var/lib/containers" + ], + "customizations": { + "vscode": { + "extensions": ["redhat.ansible", "redhat.vscode-redhat-account"] + } + } +} diff --git a/.github/ansible-code-bot.yml b/.github/ansible-code-bot.yml new file mode 100644 index 000000000..dd75c0879 --- /dev/null +++ b/.github/ansible-code-bot.yml @@ -0,0 +1,3 @@ +--- +schedule: + interval: "daily" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..4f8f08a29 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,17 @@ +--- +name: "CI" + +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: # yamllint disable-line rule:truthy + pull_request: + branches: [main] + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + ansible-lint: + uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..049f26b92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,171 @@ +.logs/* +*.retry +*.vault +collections/* +!collections/ansible_collections +!collections/requirements.yml +collections/ansible_collections/* +!collections/ansible_collections/cloudkit +collections/ansible_collections/cloudkit/* +!collections/ansible_collections/cloudkit/global_config +# https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/README.md b/README.md index cd390002a..15417c4d7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@ -# public_template +# Cloudkit Ansible Project -Use this repository as the template for public-facing repositories. Please keep the following warning at the top of the repository README: - -> [!WARNING] -> Be mindful of the content you commit to this repository. Do not commit any -> material containing Red Hat confidential content, including information about -> future product development plans. +This repository contains the Ansible roles, playbooks, rulebooks, and +inventories that are used in the scope of cloudkit. diff --git a/ansible-navigator.yml b/ansible-navigator.yml new file mode 100644 index 000000000..d9d705748 --- /dev/null +++ b/ansible-navigator.yml @@ -0,0 +1,10 @@ +--- +ansible-navigator: + logging: + level: debug + append: false + file: $PWD/.logs/ansible-navigator.log + + playbook-artifact: + enable: true + save-as: "$PWD/.logs/{playbook_name}-artifact-{time_stamp}.json" diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 000000000..6b54e7959 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,13 @@ +[defaults] +# Set the logging verbosity level +verbosity = 2 + +# Define the default become method +become_method = sudo + +[persistent_connection] +# Controls how long the persistent connection will remain idle before it is destroyed +connect_timeout=30 + +# Controls the amount of time to wait for response from remote device before timing out persistent connection +command_timeout=30 diff --git a/collections/requirements.yml b/collections/requirements.yml new file mode 100644 index 000000000..1062b362a --- /dev/null +++ b/collections/requirements.yml @@ -0,0 +1,2 @@ +--- +collections: [] diff --git a/devfile.yaml b/devfile.yaml new file mode 100644 index 000000000..f7b1723ef --- /dev/null +++ b/devfile.yaml @@ -0,0 +1,15 @@ +schemaVersion: 2.2.2 +metadata: + name: cloudkit.global_config-87d43573 +components: + - name: tooling-container + container: + image: ghcr.io/ansible/ansible-workspace-env-reference:latest + memoryRequest: 256M + memoryLimit: 6Gi + cpuRequest: 250m + cpuLimit: 2000m + args: ["tail", "-f", "/dev/null"] + env: + - name: KUBEDOCK_ENABLED + value: "true" diff --git a/inventory/localhost.yml b/inventory/localhost.yml new file mode 100644 index 000000000..c43a95464 --- /dev/null +++ b/inventory/localhost.yml @@ -0,0 +1,6 @@ +--- +all: + hosts: + config: + ansible_host: localhost + ansible_connection: local diff --git a/playbook_cloudkit_create_hosted_cluster.yml b/playbook_cloudkit_create_hosted_cluster.yml new file mode 100644 index 000000000..04f3832c8 --- /dev/null +++ b/playbook_cloudkit_create_hosted_cluster.yml @@ -0,0 +1,6 @@ +--- +- name: Create a hosted control plane cluster + hosts: localhost + gather_facts: false + + tasks: diff --git a/playbook_cloudkit_delete_hosted_cluster.yml b/playbook_cloudkit_delete_hosted_cluster.yml new file mode 100644 index 000000000..be052078f --- /dev/null +++ b/playbook_cloudkit_delete_hosted_cluster.yml @@ -0,0 +1,6 @@ +--- +- name: Delete a hosted control plane cluster + hosts: localhost + gather_facts: false + + tasks: diff --git a/roles/.gitkeep b/roles/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/rulebooks/cluster_fulfillment.yml b/rulebooks/cluster_fulfillment.yml new file mode 100644 index 000000000..d4e7a2026 --- /dev/null +++ b/rulebooks/cluster_fulfillment.yml @@ -0,0 +1,22 @@ +- name: Fulfillment webhook + hosts: localhost + ## Define our source for events + sources: + - ansible.eda.webhook: + host: 0.0.0.0 + port: 5000 + ## Define the conditions we are looking for + rules: + - name: Create hosted cluster + condition: event.payload.message == "create_hosted_cluster" + action: + run_job_template: + name: "create-hosted-cluster" + organization: "cloudkit" + + - name: Delete hosted cluster + condition: event.payload.message == "delete_hosted_cluster" + action: + run_job_template: + name: "delete-hosted-cluster" + organization: "cloudkit"