From ca109a6b01779dc70be51e71445e7da322f44a13 Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Wed, 1 May 2024 23:41:14 -0400 Subject: [PATCH 1/3] Provide a component replaces documentation generator --- docs/component-replaces-generator/main.yml | 8 +++ .../roles/docs_generator/README.md | 38 +++++++++++++ .../roles/docs_generator/defaults/main.yml | 2 + .../roles/docs_generator/handlers/main.yml | 2 + .../roles/docs_generator/meta/main.yml | 52 ++++++++++++++++++ .../tasks/generate_component_interface.yaml | 32 +++++++++++ .../roles/docs_generator/tasks/main.yml | 23 ++++++++ .../templates/component_docs.j2 | 16 ++++++ .../roles/docs_generator/tests/inventory | 2 + .../roles/docs_generator/tests/test.yml | 5 ++ .../roles/docs_generator/vars/main.yml | 2 + lib/control-plane/component_replacements.md | 21 ++++++++ .../nodeset/component_replacements.md | 22 ++++++++ .../metallb/component_replacements.md | 26 +++++++++ lib/networking/nad/component_replacements.md | 18 +++++++ .../netconfig/component_replacements.md | 28 ++++++++++ lib/nncp/component_replacements.md | 54 +++++++++++++++++++ lib/olm-openstack/component_replacements.md | 14 +++++ 18 files changed, 365 insertions(+) create mode 100644 docs/component-replaces-generator/main.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/README.md create mode 100644 docs/component-replaces-generator/roles/docs_generator/defaults/main.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/handlers/main.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/meta/main.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml create mode 100644 docs/component-replaces-generator/roles/docs_generator/tasks/main.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 create mode 100644 docs/component-replaces-generator/roles/docs_generator/tests/inventory create mode 100644 docs/component-replaces-generator/roles/docs_generator/tests/test.yml create mode 100644 docs/component-replaces-generator/roles/docs_generator/vars/main.yml create mode 100644 lib/control-plane/component_replacements.md create mode 100644 lib/dataplane/nodeset/component_replacements.md create mode 100644 lib/networking/metallb/component_replacements.md create mode 100644 lib/networking/nad/component_replacements.md create mode 100644 lib/networking/netconfig/component_replacements.md create mode 100644 lib/nncp/component_replacements.md create mode 100644 lib/olm-openstack/component_replacements.md diff --git a/docs/component-replaces-generator/main.yml b/docs/component-replaces-generator/main.yml new file mode 100644 index 000000000..0871f4fba --- /dev/null +++ b/docs/component-replaces-generator/main.yml @@ -0,0 +1,8 @@ +--- +- name: Documentation generator + hosts: localhost + gather_facts: no + tasks: + - name: Generate some documentation + ansible.builtin.import_role: + name: docs_generator diff --git a/docs/component-replaces-generator/roles/docs_generator/README.md b/docs/component-replaces-generator/roles/docs_generator/README.md new file mode 100644 index 000000000..225dd44b9 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/docs/component-replaces-generator/roles/docs_generator/defaults/main.yml b/docs/component-replaces-generator/roles/docs_generator/defaults/main.yml new file mode 100644 index 000000000..c30d51cf2 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for docs_generator diff --git a/docs/component-replaces-generator/roles/docs_generator/handlers/main.yml b/docs/component-replaces-generator/roles/docs_generator/handlers/main.yml new file mode 100644 index 000000000..794a11e03 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for docs_generator diff --git a/docs/component-replaces-generator/roles/docs_generator/meta/main.yml b/docs/component-replaces-generator/roles/docs_generator/meta/main.yml new file mode 100644 index 000000000..f79e4c3a8 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: Leif Madsen + description: Generates common component replaces requirements documentation + company: Red Hat + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: Apache-2.0 + + min_ansible_version: 2.16 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml b/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml new file mode 100644 index 000000000..4ea1205b3 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml @@ -0,0 +1,32 @@ +--- +- name: Show component contents + ansible.builtin.debug: + var: component_path + +- name: Set component name + ansible.builtin.set_fact: + component_name: "{{ component_path.split('/')[-2] | trim }}" + +- name: Set component directory + ansible.builtin.set_fact: + component_dir: "{{ component_path.split('/')[:-1] | join('/') }}" + +- name: Read contents of module + ansible.builtin.slurp: + src: "{{ component_path }}" + register: kustomization_contents + +- name: Interpret as yaml + ansible.builtin.set_fact: + kustomize_yaml: '{{ kustomization_contents.content | b64decode | from_yaml }}' + +- name: Describe which component we're working on + ansible.builtin.debug: + msg: | + Working on documentation for {{ component_name }} at {{ component_dir }} + +- name: Generate the documentation {{ component_name }} + ansible.builtin.template: + src: component_docs.j2 + dest: "{{ component_dir }}/component_replacements.md" + when: "'replacements' in kustomize_yaml" diff --git a/docs/component-replaces-generator/roles/docs_generator/tasks/main.yml b/docs/component-replaces-generator/roles/docs_generator/tasks/main.yml new file mode 100644 index 000000000..19ab1d61c --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/tasks/main.yml @@ -0,0 +1,23 @@ +--- +# tasks file for docs_generator +- name: Find common component directories + ansible.builtin.find: + paths: "{{ playbook_dir }}/../../lib/" + recurse: yes + patterns: 'kustomization.yaml' + register: common_components_index + +- name: Set common component path list + ansible.builtin.set_fact: + common_components: "{{ common_components_index.files | map(attribute='path') | list }}" + +- name: Show common components + ansible.builtin.debug: + msg: "{{ item }}" + loop: "{{ common_components }}" + +- name: Generate component interface documentation + loop: "{{ common_components }}" + ansible.builtin.include_tasks: generate_component_interface.yaml + loop_control: + loop_var: component_path diff --git a/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 new file mode 100644 index 000000000..adebb36cb --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 @@ -0,0 +1,16 @@ +--- +## Component {{ component_name }} replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +{% for replacement in kustomize_yaml.replacements %} +| {{ replacement.source.name }} | {{ replacement.source.fieldPath }} | +{% endfor %} diff --git a/docs/component-replaces-generator/roles/docs_generator/tests/inventory b/docs/component-replaces-generator/roles/docs_generator/tests/inventory new file mode 100644 index 000000000..878877b07 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/docs/component-replaces-generator/roles/docs_generator/tests/test.yml b/docs/component-replaces-generator/roles/docs_generator/tests/test.yml new file mode 100644 index 000000000..6bb88f299 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - docs_generator diff --git a/docs/component-replaces-generator/roles/docs_generator/vars/main.yml b/docs/component-replaces-generator/roles/docs_generator/vars/main.yml new file mode 100644 index 000000000..efecb2987 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for docs_generator diff --git a/lib/control-plane/component_replacements.md b/lib/control-plane/component_replacements.md new file mode 100644 index 000000000..3548186ad --- /dev/null +++ b/lib/control-plane/component_replacements.md @@ -0,0 +1,21 @@ +--- +## Component control-plane replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| network-values | data.internalapi.endpoint_annotations | +| network-values | data.ctlplane.endpoint_annotations | +| network-values | data.rabbitmq.endpoint_annotations | +| network-values | data.rabbitmq-cell1.endpoint_annotations | +| network-values | data.lbServiceType | +| network-values | data.dns-resolver.options | +| network-values | data.storageClass | +| network-values | data.bridgeName | diff --git a/lib/dataplane/nodeset/component_replacements.md b/lib/dataplane/nodeset/component_replacements.md new file mode 100644 index 000000000..831064c5d --- /dev/null +++ b/lib/dataplane/nodeset/component_replacements.md @@ -0,0 +1,22 @@ +--- +## Component nodeset replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| edpm-nodeset-values | data.nodeset.ansible | +| edpm-nodeset-values | data.nodeset.networks | +| edpm-nodeset-values | data.nodeset.nodes | +| edpm-nodeset-values | data.nodeset.services | +| edpm-nodeset-values | data.ssh_keys.authorized | +| edpm-nodeset-values | data.ssh_keys.private | +| edpm-nodeset-values | data.ssh_keys.public | +| edpm-nodeset-values | data.nova.migration.ssh_keys.private | +| edpm-nodeset-values | data.nova.migration.ssh_keys.public | diff --git a/lib/networking/metallb/component_replacements.md b/lib/networking/metallb/component_replacements.md new file mode 100644 index 000000000..af1b27b06 --- /dev/null +++ b/lib/networking/metallb/component_replacements.md @@ -0,0 +1,26 @@ +--- +## Component metallb replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| network-values | data.ctlplane.lb_addresses | +| network-values | data.internalapi.lb_addresses | +| network-values | data.storage.lb_addresses | +| network-values | data.tenant.lb_addresses | +| network-values | data.ctlplane.lb_addresses | +| network-values | data.internalapi.lb_addresses | +| network-values | data.tenant.lb_addresses | +| network-values | data.ctlplane.lb_addresses | +| network-values | data.storage.lb_addresses | +| network-values | data.bridgeName | +| network-values | data.tenant.iface | +| network-values | data.storage.iface | +| network-values | data.internalapi.iface | diff --git a/lib/networking/nad/component_replacements.md b/lib/networking/nad/component_replacements.md new file mode 100644 index 000000000..3cc1daec6 --- /dev/null +++ b/lib/networking/nad/component_replacements.md @@ -0,0 +1,18 @@ +--- +## Component nad replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| network-values | data.ctlplane.net-attach-def | +| network-values | data.internalapi.net-attach-def | +| network-values | data.storage.net-attach-def | +| network-values | data.tenant.net-attach-def | +| network-values | data.datacentre.net-attach-def | diff --git a/lib/networking/netconfig/component_replacements.md b/lib/networking/netconfig/component_replacements.md new file mode 100644 index 000000000..3b75dd574 --- /dev/null +++ b/lib/networking/netconfig/component_replacements.md @@ -0,0 +1,28 @@ +--- +## Component netconfig replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| network-values | data.ctlplane.dnsDomain | +| network-values | data.internalapi.dnsDomain | +| network-values | data.external.dnsDomain | +| network-values | data.storage.dnsDomain | +| network-values | data.tenant.dnsDomain | +| network-values | data.ctlplane.mtu | +| network-values | data.internalapi.mtu | +| network-values | data.external.mtu | +| network-values | data.storage.mtu | +| network-values | data.tenant.mtu | +| network-values | data.ctlplane.subnets | +| network-values | data.internalapi.subnets | +| network-values | data.external.subnets | +| network-values | data.storage.subnets | +| network-values | data.tenant.subnets | diff --git a/lib/nncp/component_replacements.md b/lib/nncp/component_replacements.md new file mode 100644 index 000000000..5c74ead3a --- /dev/null +++ b/lib/nncp/component_replacements.md @@ -0,0 +1,54 @@ +--- +## Component nncp replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| network-values | data.internalapi.base_iface | +| network-values | data.internalapi.vlan | +| network-values | data.internalapi.mtu | +| network-values | data.tenant.base_iface | +| network-values | data.tenant.vlan | +| network-values | data.tenant.mtu | +| network-values | data.storage.base_iface | +| network-values | data.storage.vlan | +| network-values | data.storage.mtu | +| network-values | data.ctlplane.iface | +| network-values | data.ctlplane.mtu | +| network-values | data.node_0.internalapi_ip | +| network-values | data.node_0.tenant_ip | +| network-values | data.node_0.ctlplane_ip | +| network-values | data.node_0.storage_ip | +| network-values | data.node_1.internalapi_ip | +| network-values | data.node_1.tenant_ip | +| network-values | data.node_1.ctlplane_ip | +| network-values | data.node_1.storage_ip | +| network-values | data.node_2.internalapi_ip | +| network-values | data.node_2.tenant_ip | +| network-values | data.node_2.ctlplane_ip | +| network-values | data.node_2.storage_ip | +| network-values | data.ctlplane.prefix-length | +| network-values | data.internalapi.prefix-length | +| network-values | data.tenant.prefix-length | +| network-values | data.storage.prefix-length | +| network-values | data.ctlplane.prefix-length | +| network-values | data.internalapi.prefix-length | +| network-values | data.tenant.prefix-length | +| network-values | data.storage.prefix-length | +| network-values | data.ctlplane.prefix-length | +| network-values | data.internalapi.prefix-length | +| network-values | data.tenant.prefix-length | +| network-values | data.storage.prefix-length | +| network-values | data.node_0.name | +| network-values | data.node_1.name | +| network-values | data.node_2.name | +| network-values | data.dns-resolver.config | +| network-values | data.routes | +| network-values | data.bridgeName | diff --git a/lib/olm-openstack/component_replacements.md b/lib/olm-openstack/component_replacements.md new file mode 100644 index 000000000..735272199 --- /dev/null +++ b/lib/olm-openstack/component_replacements.md @@ -0,0 +1,14 @@ +--- +## Component olm-openstack replacement requirements + +Each component expects a set of ConfigMap parameters to be passed to it so that +manifests can be generated by kustomize. + +The component expects the parameters to be set in a corresponding local +ConfigMap in the overlay. Defaults are generally not provided by the component, +and errors will be thrown if the expected parameter is missing when building +the manifests with kustomize. + +| ConfigMap source name | Parameter field path | +| ----------- | ---------- | +| olm-values | data.openstack-operator-image | From d847d7ac6e195641c14d48a5976657fc0699139e Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Wed, 1 May 2024 23:50:46 -0400 Subject: [PATCH 2/3] Add info about ConfigMap usage --- .../docs_generator/templates/component_docs.j2 | 17 +++++++++++++++++ lib/control-plane/component_replacements.md | 17 +++++++++++++++++ lib/dataplane/nodeset/component_replacements.md | 17 +++++++++++++++++ .../metallb/component_replacements.md | 17 +++++++++++++++++ lib/networking/nad/component_replacements.md | 17 +++++++++++++++++ .../netconfig/component_replacements.md | 17 +++++++++++++++++ lib/nncp/component_replacements.md | 17 +++++++++++++++++ lib/olm-openstack/component_replacements.md | 17 +++++++++++++++++ 8 files changed, 136 insertions(+) diff --git a/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 index adebb36cb..da1ac9a49 100644 --- a/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 +++ b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 @@ -14,3 +14,20 @@ the manifests with kustomize. {% for replacement in kustomize_yaml.replacements %} | {{ replacement.source.name }} | {{ replacement.source.fieldPath }} | {% endfor %} + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/control-plane/component_replacements.md b/lib/control-plane/component_replacements.md index 3548186ad..cc5de24f0 100644 --- a/lib/control-plane/component_replacements.md +++ b/lib/control-plane/component_replacements.md @@ -19,3 +19,20 @@ the manifests with kustomize. | network-values | data.dns-resolver.options | | network-values | data.storageClass | | network-values | data.bridgeName | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/dataplane/nodeset/component_replacements.md b/lib/dataplane/nodeset/component_replacements.md index 831064c5d..1e31b8f71 100644 --- a/lib/dataplane/nodeset/component_replacements.md +++ b/lib/dataplane/nodeset/component_replacements.md @@ -20,3 +20,20 @@ the manifests with kustomize. | edpm-nodeset-values | data.ssh_keys.public | | edpm-nodeset-values | data.nova.migration.ssh_keys.private | | edpm-nodeset-values | data.nova.migration.ssh_keys.public | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/networking/metallb/component_replacements.md b/lib/networking/metallb/component_replacements.md index af1b27b06..ffb11a13a 100644 --- a/lib/networking/metallb/component_replacements.md +++ b/lib/networking/metallb/component_replacements.md @@ -24,3 +24,20 @@ the manifests with kustomize. | network-values | data.tenant.iface | | network-values | data.storage.iface | | network-values | data.internalapi.iface | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/networking/nad/component_replacements.md b/lib/networking/nad/component_replacements.md index 3cc1daec6..76f2ab085 100644 --- a/lib/networking/nad/component_replacements.md +++ b/lib/networking/nad/component_replacements.md @@ -16,3 +16,20 @@ the manifests with kustomize. | network-values | data.storage.net-attach-def | | network-values | data.tenant.net-attach-def | | network-values | data.datacentre.net-attach-def | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/networking/netconfig/component_replacements.md b/lib/networking/netconfig/component_replacements.md index 3b75dd574..d74971875 100644 --- a/lib/networking/netconfig/component_replacements.md +++ b/lib/networking/netconfig/component_replacements.md @@ -26,3 +26,20 @@ the manifests with kustomize. | network-values | data.external.subnets | | network-values | data.storage.subnets | | network-values | data.tenant.subnets | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/nncp/component_replacements.md b/lib/nncp/component_replacements.md index 5c74ead3a..1e336f84a 100644 --- a/lib/nncp/component_replacements.md +++ b/lib/nncp/component_replacements.md @@ -52,3 +52,20 @@ the manifests with kustomize. | network-values | data.dns-resolver.config | | network-values | data.routes | | network-values | data.bridgeName | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` diff --git a/lib/olm-openstack/component_replacements.md b/lib/olm-openstack/component_replacements.md index 735272199..bfb0371ce 100644 --- a/lib/olm-openstack/component_replacements.md +++ b/lib/olm-openstack/component_replacements.md @@ -12,3 +12,20 @@ the manifests with kustomize. | ConfigMap source name | Parameter field path | | ----------- | ---------- | | olm-values | data.openstack-operator-image | + +### Creating the local ConfigMap file + +In the overlay, create a file that will hold the parameters for the component which will be later included as a resource within the `kustomization.yaml` file. The resource name may match the ConfigMap source name with `.yaml` appended or another filename such as `values.yaml`. + +```yaml +# local-config: referenced, but not emitted by kustomize +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: + annotations: + config.kubernetes.io/local-config: "true" +data: + : "" +``` From 2b7ae37444eac5a05b000191e0a43f40b7ffac5c Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Thu, 2 May 2024 12:02:20 -0400 Subject: [PATCH 3/3] Add ConfigMap generator to docs Attempt to generate a sample ConfigMap in the component_replacements.md markdown documentation to make it easier to know how to consume the component and setup resources. --- .../docs_generator/filter_plugins/.gitignore | 1 + .../docs_generator/filter_plugins/tree.py | 22 +++++ .../tasks/generate_component_interface.yaml | 23 +++++ .../templates/component_docs.j2 | 5 +- lib/control-plane/component_replacements.md | 54 ++++++++++- .../nodeset/component_replacements.md | 68 +++++++++++++- .../metallb/component_replacements.md | 76 ++++++++++++++- lib/networking/nad/component_replacements.md | 82 +++++++++++++++- .../netconfig/component_replacements.md | 94 ++++++++++++++++++- lib/nncp/component_replacements.md | 45 ++++++++- lib/olm-openstack/component_replacements.md | 69 +++++++++++++- 11 files changed, 522 insertions(+), 17 deletions(-) create mode 100644 docs/component-replaces-generator/roles/docs_generator/filter_plugins/.gitignore create mode 100644 docs/component-replaces-generator/roles/docs_generator/filter_plugins/tree.py diff --git a/docs/component-replaces-generator/roles/docs_generator/filter_plugins/.gitignore b/docs/component-replaces-generator/roles/docs_generator/filter_plugins/.gitignore new file mode 100644 index 000000000..96403d36f --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/filter_plugins/.gitignore @@ -0,0 +1 @@ +__pycache__/* diff --git a/docs/component-replaces-generator/roles/docs_generator/filter_plugins/tree.py b/docs/component-replaces-generator/roles/docs_generator/filter_plugins/tree.py new file mode 100644 index 000000000..63ea93e58 --- /dev/null +++ b/docs/component-replaces-generator/roles/docs_generator/filter_plugins/tree.py @@ -0,0 +1,22 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +ANSIBLE_METADATA = { + 'metadata_version': '0.1', + 'status': ['preview'], + 'supported_by': 'community' +} + +class FilterModule(object): + def filters(self): + return { + 'tree': self.tree_builder + } + + def tree_builder(self, value): + tree = {} + + t = tree + for part in value.split('.'): + t = t.setdefault(part, {}) + return tree diff --git a/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml b/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml index 4ea1205b3..6e7e02420 100644 --- a/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml +++ b/docs/component-replaces-generator/roles/docs_generator/tasks/generate_component_interface.yaml @@ -20,6 +20,29 @@ ansible.builtin.set_fact: kustomize_yaml: '{{ kustomization_contents.content | b64decode | from_yaml }}' +- name: Show yaml + ansible.builtin.debug: + var: kustomize_yaml + +- name: Get all the fieldpaths + ansible.builtin.set_fact: + fieldpaths: "{{ fieldpaths|default([]) + [item.source.fieldPath] }}" + loop: "{{ kustomize_yaml.replacements }}" + when: "'replacements' in kustomize_yaml" + +- name: Show replacements + ansible.builtin.debug: + var: fieldpaths + +- name: Build new structure + loop: "{{ fieldpaths }}" + ansible.builtin.set_fact: + source_dict: "{{ source_dict|default({}) | combine(item | tree, recursive=True) }}" + +- name: Show source_dict + ansible.builtin.debug: + var: source_dict + - name: Describe which component we're working on ansible.builtin.debug: msg: | diff --git a/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 index da1ac9a49..0f1ebfe94 100644 --- a/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 +++ b/docs/component-replaces-generator/roles/docs_generator/templates/component_docs.j2 @@ -25,9 +25,8 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" -data: - : "" +{{ source_dict | to_nice_yaml }} ``` diff --git a/lib/control-plane/component_replacements.md b/lib/control-plane/component_replacements.md index cc5de24f0..3854e13e5 100644 --- a/lib/control-plane/component_replacements.md +++ b/lib/control-plane/component_replacements.md @@ -30,9 +30,59 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + endpoint_annotations: {} + iface: {} + mtu: {} + prefix-length: {} + dns-resolver: + config: {} + options: {} + internalapi: + base_iface: {} + endpoint_annotations: {} + mtu: {} + prefix-length: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + storage: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + ``` diff --git a/lib/dataplane/nodeset/component_replacements.md b/lib/dataplane/nodeset/component_replacements.md index 1e31b8f71..1eeb3317b 100644 --- a/lib/dataplane/nodeset/component_replacements.md +++ b/lib/dataplane/nodeset/component_replacements.md @@ -31,9 +31,73 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + endpoint_annotations: {} + iface: {} + mtu: {} + prefix-length: {} + dns-resolver: + config: {} + options: {} + internalapi: + base_iface: {} + endpoint_annotations: {} + mtu: {} + prefix-length: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + nodeset: + ansible: {} + networks: {} + nodes: {} + services: {} + nova: + migration: + ssh_keys: + private: {} + public: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + ssh_keys: + authorized: {} + private: {} + public: {} + storage: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + ``` diff --git a/lib/networking/metallb/component_replacements.md b/lib/networking/metallb/component_replacements.md index ffb11a13a..3a064dbd2 100644 --- a/lib/networking/metallb/component_replacements.md +++ b/lib/networking/metallb/component_replacements.md @@ -35,9 +35,81 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + prefix-length: {} + dns-resolver: + config: {} + options: {} + internalapi: + base_iface: {} + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + prefix-length: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + nodeset: + ansible: {} + networks: {} + nodes: {} + services: {} + nova: + migration: + ssh_keys: + private: {} + public: {} + openstack-operator-image: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + ssh_keys: + authorized: {} + private: {} + public: {} + storage: + base_iface: {} + iface: {} + lb_addresses: {} + mtu: {} + prefix-length: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + iface: {} + lb_addresses: {} + mtu: {} + prefix-length: {} + vlan: {} + ``` diff --git a/lib/networking/nad/component_replacements.md b/lib/networking/nad/component_replacements.md index 76f2ab085..540461b57 100644 --- a/lib/networking/nad/component_replacements.md +++ b/lib/networking/nad/component_replacements.md @@ -27,9 +27,87 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + datacentre: + net-attach-def: {} + dns-resolver: + config: {} + options: {} + internalapi: + base_iface: {} + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + nodeset: + ansible: {} + networks: {} + nodes: {} + services: {} + nova: + migration: + ssh_keys: + private: {} + public: {} + openstack-operator-image: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + ssh_keys: + authorized: {} + private: {} + public: {} + storage: + base_iface: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + vlan: {} + ``` diff --git a/lib/networking/netconfig/component_replacements.md b/lib/networking/netconfig/component_replacements.md index d74971875..d83a304e8 100644 --- a/lib/networking/netconfig/component_replacements.md +++ b/lib/networking/netconfig/component_replacements.md @@ -37,9 +37,99 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + dnsDomain: {} + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + subnets: {} + datacentre: + net-attach-def: {} + dns-resolver: + config: {} + options: {} + external: + dnsDomain: {} + mtu: {} + subnets: {} + internalapi: + base_iface: {} + dnsDomain: {} + endpoint_annotations: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + subnets: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + nodeset: + ansible: {} + networks: {} + nodes: {} + services: {} + nova: + migration: + ssh_keys: + private: {} + public: {} + openstack-operator-image: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + ssh_keys: + authorized: {} + private: {} + public: {} + storage: + base_iface: {} + dnsDomain: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + subnets: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + dnsDomain: {} + iface: {} + lb_addresses: {} + mtu: {} + net-attach-def: {} + prefix-length: {} + subnets: {} + vlan: {} + ``` diff --git a/lib/nncp/component_replacements.md b/lib/nncp/component_replacements.md index 1e336f84a..b86647dc0 100644 --- a/lib/nncp/component_replacements.md +++ b/lib/nncp/component_replacements.md @@ -63,9 +63,50 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + iface: {} + mtu: {} + prefix-length: {} + dns-resolver: + config: {} + internalapi: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + routes: {} + storage: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + tenant: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + ``` diff --git a/lib/olm-openstack/component_replacements.md b/lib/olm-openstack/component_replacements.md index bfb0371ce..334344a34 100644 --- a/lib/olm-openstack/component_replacements.md +++ b/lib/olm-openstack/component_replacements.md @@ -23,9 +23,74 @@ In the overlay, create a file that will hold the parameters for the component wh apiVersion: v1 kind: ConfigMap metadata: - name: + name: annotations: config.kubernetes.io/local-config: "true" data: - : "" + bridgeName: {} + ctlplane: + endpoint_annotations: {} + iface: {} + mtu: {} + prefix-length: {} + dns-resolver: + config: {} + options: {} + internalapi: + base_iface: {} + endpoint_annotations: {} + mtu: {} + prefix-length: {} + vlan: {} + lbServiceType: {} + node_0: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_1: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + node_2: + ctlplane_ip: {} + internalapi_ip: {} + name: {} + storage_ip: {} + tenant_ip: {} + nodeset: + ansible: {} + networks: {} + nodes: {} + services: {} + nova: + migration: + ssh_keys: + private: {} + public: {} + openstack-operator-image: {} + rabbitmq: + endpoint_annotations: {} + rabbitmq-cell1: + endpoint_annotations: {} + routes: {} + ssh_keys: + authorized: {} + private: {} + public: {} + storage: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + storageClass: {} + tenant: + base_iface: {} + mtu: {} + prefix-length: {} + vlan: {} + ```