From b063db8dc1130e84ca96468947e51c63eadaceb5 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 13 Mar 2024 19:14:08 +0930 Subject: [PATCH] feat: restructure repository as ansible collection BREAKING CHANGE: Repository restructure from Ansible Role to Ansible Collection !37 --- CONTRIBUTING.md | 4 +- README-orig.md | 39 --------- galaxy.yml | 84 +++++++++++++++++++ meta/runtime.yml | 52 ++++++++++++ plugins/.gitkeep | 0 .../nfc_kubernetes/defaults}/main.yml | 0 .../nfc_kubernetes/handlers}/main.yml | 0 {meta => roles/nfc_kubernetes/meta}/main.yml | 1 - .../nfc_kubernetes/tasks}/helm/main.yaml | 0 .../nfc_kubernetes/tasks}/k3s/configure.yaml | 0 .../nfc_kubernetes/tasks}/k3s/install.yaml | 0 .../tasks}/k3s/manifest_apply.yaml | 0 .../tasks}/k3s/migrate_to_operator.yaml | 0 .../nfc_kubernetes/tasks}/kubevirt/main.yaml | 0 .../tasks}/kubevirt/validate.yaml | 0 .../nfc_kubernetes/tasks}/main.yml | 0 ...nifest-network_default_network_policy.yaml | 0 ...etwork_default_network_policy_kubeDNS.yaml | 0 ...anifest-network_disallow-mutable-tags.yaml | 0 ...st-network_disallow_default_namespace.yaml | 0 ...cy-manifest-topology-constraint-nodes.yaml | 0 ...-manifest-kube-metrics-metrics_server.yaml | 0 .../APIServer-manifest-Calico_Cluster.yaml | 0 ...p-manifest-Calico_Service_Endpoint.yaml.j2 | 0 ...eployment-manifest-Calico_Operator.yaml.j2 | 0 ...ployment-manifest-MetalLB_Operator.yaml.j2 | 0 ...Configuration-manifest-Calico_Cluster.yaml | 0 .../IPPool-manifest-Calico_Cluster.yaml.j2 | 0 ...stallation-manifest-Calico_Cluster.yaml.j2 | 0 .../nfc_kubernetes/templates}/calico.yaml.j2 | 0 .../etc_cni_net.d_100-crio-bridge.conf.j2 | 0 .../templates}/iptables-kubernetes.rules.j2 | 0 .../templates}/k3s-config.yaml.j2 | 0 .../templates}/k3s-registries.yaml.j2 | 0 .../kubernetes-manifest-rbac.yaml.j2 | 0 .../templates}/kubevirt-cr.yaml.j2 | 0 .../templates}/kubevirt-operator.yaml.j2 | 0 37 files changed, 138 insertions(+), 42 deletions(-) delete mode 100644 README-orig.md create mode 100644 galaxy.yml create mode 100644 meta/runtime.yml create mode 100644 plugins/.gitkeep rename {defaults => roles/nfc_kubernetes/defaults}/main.yml (100%) rename {handlers => roles/nfc_kubernetes/handlers}/main.yml (100%) rename {meta => roles/nfc_kubernetes/meta}/main.yml (98%) rename {tasks => roles/nfc_kubernetes/tasks}/helm/main.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/k3s/configure.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/k3s/install.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/k3s/manifest_apply.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/k3s/migrate_to_operator.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/kubevirt/main.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/kubevirt/validate.yaml (100%) rename {tasks => roles/nfc_kubernetes/tasks}/main.yml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/ClusterPolicy-manifest-network_default_network_policy.yaml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/ClusterPolicy-manifest-network_default_network_policy_kubeDNS.yaml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/ClusterPolicy-manifest-network_disallow-mutable-tags.yaml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/ClusterPolicy-manifest-network_disallow_default_namespace.yaml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/ClusterPolicy-manifest-topology-constraint-nodes.yaml (100%) rename {template-manifests => roles/nfc_kubernetes/template-manifests}/NetworkPolicy-manifest-kube-metrics-metrics_server.yaml (100%) rename {templates => roles/nfc_kubernetes/templates}/APIServer-manifest-Calico_Cluster.yaml (100%) rename {templates => roles/nfc_kubernetes/templates}/ConfigMap-manifest-Calico_Service_Endpoint.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/Deployment-manifest-Calico_Operator.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/Deployment-manifest-MetalLB_Operator.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/FelixConfiguration-manifest-Calico_Cluster.yaml (100%) rename {templates => roles/nfc_kubernetes/templates}/IPPool-manifest-Calico_Cluster.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/Installation-manifest-Calico_Cluster.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/calico.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/etc_cni_net.d_100-crio-bridge.conf.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/iptables-kubernetes.rules.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/k3s-config.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/k3s-registries.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/kubernetes-manifest-rbac.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/kubevirt-cr.yaml.j2 (100%) rename {templates => roles/nfc_kubernetes/templates}/kubevirt-operator.yaml.j2 (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 992c42b..46b3745 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,10 +15,10 @@ Some components within this role are sourced from a remote source. To update the export KUBEVIRT_RELEASE='' -# From within the templates directory +# From within roles/nfc_kubernetes/templates directory wget https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_RELEASE}/kubevirt-operator.yaml -O kubevirt-operator.yaml.j2 -# From within the templates directory +# From within the roles/nfc_kubernetes/templates directory wget https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_RELEASE}/kubevirt-cr.yaml -O kubevirt-cr.yaml.j2 ``` diff --git a/README-orig.md b/README-orig.md deleted file mode 100644 index 356b5db..0000000 --- a/README-orig.md +++ /dev/null @@ -1,39 +0,0 @@ -# Kubernetes Ansible Playbook - - -## Additional changes - -- `SystemdCgroup = false` -> `SystemdCgroup = true` [See this comment](https://github.com/kubernetes/kubernetes/issues/110177#issuecomment-1161647736) - -## Tags - -This role has been setup to take advantage of Ansible tags. The use of these tags enables finer control over what tasks are run. By design, when you set a task, only what is required for the tag is run. - -available tags are as follows - -- `containerregistry` apply container/docker registry settings -- `firewall` apply firewall settings (firewall name/type independent) -- `install` Run every task within the role. this is the same as omitting `--tags` -- `iptables` apply iptables settings -- `manifest` Apply/remove kubernetes manifests -- `namespace` Apply/remove kubernetes namespaces -- `nodelabels` Apply/remove kubernetes node labels -- `taints` Apply/remove kubernetes taints - -!!! tip - if you intend on running the `install` tag, you can omit the `--tags` flag from the ansible tag all togther - -!!! alert - the first time this playbook is run if cli switch `--extra-vars "init=true"` is used with `init` either a bool true/false, the manifests will not be applied. this is to enable the kubernetes to be fully setup prior to applying manifests that may prevent successful completion of the play. - -## command Cheatsheet - -- `crictl --runtime-endpoint unix:///run/containerd/containerd.sock images` list all container images on the host - -## Links / References - -- ContainerD Configuration - - - [Registry Configuration](https://github.com/containerd/containerd/blob/7cd72cce99c8d3b938c1b763c2744a0b699028ab/docs/cri/config.md#registry-configuration) - - - [Configuring ContainerD registries](https://github.com/containerd/containerd/blob/7cd72cce99c8d3b938c1b763c2744a0b699028ab/docs/hosts.md#cri) diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 0000000..66f3936 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,84 @@ +### REQUIRED +# The namespace of the collection. This can be a company/brand/organization or product namespace under which all +# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with +# underscores or numbers and cannot contain consecutive underscores +namespace: nofusscomputing + +# The name of the collection. Has the same character restrictions as 'namespace' +name: kubernetes + +# The version of the collection. Must be compatible with semantic versioning +version: 0.3.0 + +# The path to the Markdown (.md) readme file. This path is relative to the root of the collection +readme: README.md + +# A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) +# @nicks:irc/im.site#channel' +authors: + - No Fuss Computing + + +### OPTIONAL but strongly recommended +# A short summary description of the collection +description: Install a K3s Kubernetes Cluster + +# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only +# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' +license: + - MIT + +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: '' + +# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character +# requirements as 'namespace' and 'name' +tags: + - k3s + - kubernetes + - tools + +# Collections that this collection requires to be installed for it to be usable. The key of the dict is the +# collection label 'namespace.name'. The value is a version range +# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version +# range specifiers can be set and are separated by ',' +dependencies: + kubernetes.core: '3.0.0' + + +# The URL of the originating SCM repository +repository: https://gitlab.com/nofusscomputing/projects/ansible/collections/kubernetes + +# The URL to any online docs +documentation: https://nofusscomputing.com/projects/ansible/collection/kubernetes/ + +# The URL to the homepage of the collection/project +# homepage: https://example.com + +# The URL to the collection issue tracker +issues: https://gitlab.com/nofusscomputing/projects/ansible/collections/kubernetes/-/issues + +# A list of file glob-like patterns used to filter any files or directories that should not be included in the build +# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This +# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', +# and '.git' are always filtered. Mutually exclusive with 'manifest' +build_ignore: + - .vscode/ + - artifacts/ + - docs/ + - .gitlab* + - includes/ + - website-template/ + - .ansible-lint-ignore + - .cz.yaml + - .nfc_automation.yaml + - dockerfile + - mkdocs.yaml + +# A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a +# list of MANIFEST.in style +# L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key +# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive +# with 'build_ignore' +# manifest: null diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 0000000..1b573f6 --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,52 @@ +--- +# Collections must specify a minimum required ansible version to upload +# to galaxy +requires_ansible: '>=2.14.0' + +# Content that Ansible needs to load from another location or that has +# been deprecated/removed +# plugin_routing: +# action: +# redirected_plugin_name: +# redirect: ns.col.new_location +# deprecated_plugin_name: +# deprecation: +# removal_version: "4.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# removed_plugin_name: +# tombstone: +# removal_version: "2.0.0" +# warning_text: | +# See the porting guide on how to update your playbook to +# use ns.col.another_plugin instead. +# become: +# cache: +# callback: +# cliconf: +# connection: +# doc_fragments: +# filter: +# httpapi: +# inventory: +# lookup: +# module_utils: +# modules: +# netconf: +# shell: +# strategy: +# terminal: +# test: +# vars: + +# Python import statements that Ansible needs to load from another location +# import_redirection: +# ansible_collections.ns.col.plugins.module_utils.old_location: +# redirect: ansible_collections.ns.col.plugins.module_utils.new_location + +# Groups of actions/modules that take a common set of options +# action_groups: +# group_name: +# - module1 +# - module2 diff --git a/plugins/.gitkeep b/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/defaults/main.yml b/roles/nfc_kubernetes/defaults/main.yml similarity index 100% rename from defaults/main.yml rename to roles/nfc_kubernetes/defaults/main.yml diff --git a/handlers/main.yml b/roles/nfc_kubernetes/handlers/main.yml similarity index 100% rename from handlers/main.yml rename to roles/nfc_kubernetes/handlers/main.yml diff --git a/meta/main.yml b/roles/nfc_kubernetes/meta/main.yml similarity index 98% rename from meta/main.yml rename to roles/nfc_kubernetes/meta/main.yml index 454c3bc..da09d8f 100644 --- a/meta/main.yml +++ b/roles/nfc_kubernetes/meta/main.yml @@ -19,6 +19,5 @@ galaxy_info: galaxy_tags: - k3s - - k8s - kubernetes - container diff --git a/tasks/helm/main.yaml b/roles/nfc_kubernetes/tasks/helm/main.yaml similarity index 100% rename from tasks/helm/main.yaml rename to roles/nfc_kubernetes/tasks/helm/main.yaml diff --git a/tasks/k3s/configure.yaml b/roles/nfc_kubernetes/tasks/k3s/configure.yaml similarity index 100% rename from tasks/k3s/configure.yaml rename to roles/nfc_kubernetes/tasks/k3s/configure.yaml diff --git a/tasks/k3s/install.yaml b/roles/nfc_kubernetes/tasks/k3s/install.yaml similarity index 100% rename from tasks/k3s/install.yaml rename to roles/nfc_kubernetes/tasks/k3s/install.yaml diff --git a/tasks/k3s/manifest_apply.yaml b/roles/nfc_kubernetes/tasks/k3s/manifest_apply.yaml similarity index 100% rename from tasks/k3s/manifest_apply.yaml rename to roles/nfc_kubernetes/tasks/k3s/manifest_apply.yaml diff --git a/tasks/k3s/migrate_to_operator.yaml b/roles/nfc_kubernetes/tasks/k3s/migrate_to_operator.yaml similarity index 100% rename from tasks/k3s/migrate_to_operator.yaml rename to roles/nfc_kubernetes/tasks/k3s/migrate_to_operator.yaml diff --git a/tasks/kubevirt/main.yaml b/roles/nfc_kubernetes/tasks/kubevirt/main.yaml similarity index 100% rename from tasks/kubevirt/main.yaml rename to roles/nfc_kubernetes/tasks/kubevirt/main.yaml diff --git a/tasks/kubevirt/validate.yaml b/roles/nfc_kubernetes/tasks/kubevirt/validate.yaml similarity index 100% rename from tasks/kubevirt/validate.yaml rename to roles/nfc_kubernetes/tasks/kubevirt/validate.yaml diff --git a/tasks/main.yml b/roles/nfc_kubernetes/tasks/main.yml similarity index 100% rename from tasks/main.yml rename to roles/nfc_kubernetes/tasks/main.yml diff --git a/template-manifests/ClusterPolicy-manifest-network_default_network_policy.yaml b/roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_default_network_policy.yaml similarity index 100% rename from template-manifests/ClusterPolicy-manifest-network_default_network_policy.yaml rename to roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_default_network_policy.yaml diff --git a/template-manifests/ClusterPolicy-manifest-network_default_network_policy_kubeDNS.yaml b/roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_default_network_policy_kubeDNS.yaml similarity index 100% rename from template-manifests/ClusterPolicy-manifest-network_default_network_policy_kubeDNS.yaml rename to roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_default_network_policy_kubeDNS.yaml diff --git a/template-manifests/ClusterPolicy-manifest-network_disallow-mutable-tags.yaml b/roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_disallow-mutable-tags.yaml similarity index 100% rename from template-manifests/ClusterPolicy-manifest-network_disallow-mutable-tags.yaml rename to roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_disallow-mutable-tags.yaml diff --git a/template-manifests/ClusterPolicy-manifest-network_disallow_default_namespace.yaml b/roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_disallow_default_namespace.yaml similarity index 100% rename from template-manifests/ClusterPolicy-manifest-network_disallow_default_namespace.yaml rename to roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-network_disallow_default_namespace.yaml diff --git a/template-manifests/ClusterPolicy-manifest-topology-constraint-nodes.yaml b/roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-topology-constraint-nodes.yaml similarity index 100% rename from template-manifests/ClusterPolicy-manifest-topology-constraint-nodes.yaml rename to roles/nfc_kubernetes/template-manifests/ClusterPolicy-manifest-topology-constraint-nodes.yaml diff --git a/template-manifests/NetworkPolicy-manifest-kube-metrics-metrics_server.yaml b/roles/nfc_kubernetes/template-manifests/NetworkPolicy-manifest-kube-metrics-metrics_server.yaml similarity index 100% rename from template-manifests/NetworkPolicy-manifest-kube-metrics-metrics_server.yaml rename to roles/nfc_kubernetes/template-manifests/NetworkPolicy-manifest-kube-metrics-metrics_server.yaml diff --git a/templates/APIServer-manifest-Calico_Cluster.yaml b/roles/nfc_kubernetes/templates/APIServer-manifest-Calico_Cluster.yaml similarity index 100% rename from templates/APIServer-manifest-Calico_Cluster.yaml rename to roles/nfc_kubernetes/templates/APIServer-manifest-Calico_Cluster.yaml diff --git a/templates/ConfigMap-manifest-Calico_Service_Endpoint.yaml.j2 b/roles/nfc_kubernetes/templates/ConfigMap-manifest-Calico_Service_Endpoint.yaml.j2 similarity index 100% rename from templates/ConfigMap-manifest-Calico_Service_Endpoint.yaml.j2 rename to roles/nfc_kubernetes/templates/ConfigMap-manifest-Calico_Service_Endpoint.yaml.j2 diff --git a/templates/Deployment-manifest-Calico_Operator.yaml.j2 b/roles/nfc_kubernetes/templates/Deployment-manifest-Calico_Operator.yaml.j2 similarity index 100% rename from templates/Deployment-manifest-Calico_Operator.yaml.j2 rename to roles/nfc_kubernetes/templates/Deployment-manifest-Calico_Operator.yaml.j2 diff --git a/templates/Deployment-manifest-MetalLB_Operator.yaml.j2 b/roles/nfc_kubernetes/templates/Deployment-manifest-MetalLB_Operator.yaml.j2 similarity index 100% rename from templates/Deployment-manifest-MetalLB_Operator.yaml.j2 rename to roles/nfc_kubernetes/templates/Deployment-manifest-MetalLB_Operator.yaml.j2 diff --git a/templates/FelixConfiguration-manifest-Calico_Cluster.yaml b/roles/nfc_kubernetes/templates/FelixConfiguration-manifest-Calico_Cluster.yaml similarity index 100% rename from templates/FelixConfiguration-manifest-Calico_Cluster.yaml rename to roles/nfc_kubernetes/templates/FelixConfiguration-manifest-Calico_Cluster.yaml diff --git a/templates/IPPool-manifest-Calico_Cluster.yaml.j2 b/roles/nfc_kubernetes/templates/IPPool-manifest-Calico_Cluster.yaml.j2 similarity index 100% rename from templates/IPPool-manifest-Calico_Cluster.yaml.j2 rename to roles/nfc_kubernetes/templates/IPPool-manifest-Calico_Cluster.yaml.j2 diff --git a/templates/Installation-manifest-Calico_Cluster.yaml.j2 b/roles/nfc_kubernetes/templates/Installation-manifest-Calico_Cluster.yaml.j2 similarity index 100% rename from templates/Installation-manifest-Calico_Cluster.yaml.j2 rename to roles/nfc_kubernetes/templates/Installation-manifest-Calico_Cluster.yaml.j2 diff --git a/templates/calico.yaml.j2 b/roles/nfc_kubernetes/templates/calico.yaml.j2 similarity index 100% rename from templates/calico.yaml.j2 rename to roles/nfc_kubernetes/templates/calico.yaml.j2 diff --git a/templates/etc_cni_net.d_100-crio-bridge.conf.j2 b/roles/nfc_kubernetes/templates/etc_cni_net.d_100-crio-bridge.conf.j2 similarity index 100% rename from templates/etc_cni_net.d_100-crio-bridge.conf.j2 rename to roles/nfc_kubernetes/templates/etc_cni_net.d_100-crio-bridge.conf.j2 diff --git a/templates/iptables-kubernetes.rules.j2 b/roles/nfc_kubernetes/templates/iptables-kubernetes.rules.j2 similarity index 100% rename from templates/iptables-kubernetes.rules.j2 rename to roles/nfc_kubernetes/templates/iptables-kubernetes.rules.j2 diff --git a/templates/k3s-config.yaml.j2 b/roles/nfc_kubernetes/templates/k3s-config.yaml.j2 similarity index 100% rename from templates/k3s-config.yaml.j2 rename to roles/nfc_kubernetes/templates/k3s-config.yaml.j2 diff --git a/templates/k3s-registries.yaml.j2 b/roles/nfc_kubernetes/templates/k3s-registries.yaml.j2 similarity index 100% rename from templates/k3s-registries.yaml.j2 rename to roles/nfc_kubernetes/templates/k3s-registries.yaml.j2 diff --git a/templates/kubernetes-manifest-rbac.yaml.j2 b/roles/nfc_kubernetes/templates/kubernetes-manifest-rbac.yaml.j2 similarity index 100% rename from templates/kubernetes-manifest-rbac.yaml.j2 rename to roles/nfc_kubernetes/templates/kubernetes-manifest-rbac.yaml.j2 diff --git a/templates/kubevirt-cr.yaml.j2 b/roles/nfc_kubernetes/templates/kubevirt-cr.yaml.j2 similarity index 100% rename from templates/kubevirt-cr.yaml.j2 rename to roles/nfc_kubernetes/templates/kubevirt-cr.yaml.j2 diff --git a/templates/kubevirt-operator.yaml.j2 b/roles/nfc_kubernetes/templates/kubevirt-operator.yaml.j2 similarity index 100% rename from templates/kubevirt-operator.yaml.j2 rename to roles/nfc_kubernetes/templates/kubevirt-operator.yaml.j2