diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95780031..0c05f732 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 with: - path: ansible_collections/community/kubernetes + path: ansible_collections/kubernetes/core - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v1 @@ -31,7 +31,7 @@ jobs: - name: Run sanity tests on Python ${{ matrix.python_version }} run: make test-sanity PYTHON_VERSION=${{ matrix.python_version }} - working-directory: ./ansible_collections/community/kubernetes + working-directory: ./ansible_collections/kubernetes/core integration: runs-on: ubuntu-latest @@ -43,7 +43,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 with: - path: ansible_collections/community/kubernetes + path: ansible_collections/kubernetes/core - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v1 @@ -55,11 +55,11 @@ jobs: - name: Run integration tests on Python ${{ matrix.python_version }} run: make test-integration PYTHON_VERSION=${{ matrix.python_version }} - working-directory: ./ansible_collections/community/kubernetes + working-directory: ./ansible_collections/kubernetes/core - name: Generate coverage report. run: ansible-test coverage xml -v --requirements --group-by command --group-by version - working-directory: ./ansible_collections/community/kubernetes + working-directory: ./ansible_collections/kubernetes/core - uses: codecov/codecov-action@v1 with: @@ -74,7 +74,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 with: - path: ansible_collections/community/kubernetes + path: ansible_collections/kubernetes/core - name: Set up KinD cluster uses: engineerd/setup-kind@v0.5.0 @@ -110,7 +110,7 @@ jobs: - name: Run molecule default test scenario run: make test-molecule - working-directory: ./ansible_collections/community/kubernetes + working-directory: ./ansible_collections/kubernetes/core unit: runs-on: ubuntu-latest @@ -121,7 +121,7 @@ jobs: - name: Check out code uses: actions/checkout@v2 with: - path: ansible_collections/community/kubernetes + path: ansible_collections/kubernetes/core - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v1 @@ -133,82 +133,4 @@ jobs: - name: Run unit tests on Python ${{ matrix.python_version }} run: make test-unit PYTHON_VERSION=${{ matrix.python_version }} - working-directory: ./ansible_collections/community/kubernetes - - downstream-sanity-29: - runs-on: ubuntu-latest - strategy: - matrix: - python_version: ['3.7'] - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/community/kubernetes - - - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python_version }} - - - name: Install ansible base (devel branch) - run: pip install "ansible>=2.9.0,<2.10.0" - - - name: Run sanity tests on Python ${{ matrix.python_version }} - run: make downstream-test-sanity - working-directory: ./ansible_collections/community/kubernetes - - downstream-integration-29: - runs-on: ubuntu-latest - strategy: - matrix: - # Our old integration tests fail under newer Python versions. - python_version: ['3.6'] - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/community/kubernetes - - - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python_version }} - - - name: Install ansible base (devel branch) - run: pip install "ansible>=2.9.0,<2.10.0" pip==20.3.1 - - - name: Run integration tests on Python ${{ matrix.python_version }} - run: make downstream-test-integration - working-directory: ./ansible_collections/community/kubernetes - - downstream-molecule-29: - runs-on: ubuntu-latest - strategy: - matrix: - python_version: ['3.7'] - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - path: ansible_collections/community/kubernetes - - - name: Set up KinD cluster - uses: engineerd/setup-kind@v0.5.0 - - - name: Set up Python ${{ matrix.python_version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python_version }} - - - name: Install molecule and openshift dependencies - run: pip install "ansible>=2.9.0,<2.10.0" "molecule<3.3.0" yamllint openshift flake8 - - - name: Create default collection path symlink - run: | - mkdir -p /home/runner/.ansible - ln -s /home/runner/work/kubernetes/kubernetes /home/runner/.ansible/collections - - - name: Run molecule default test scenario - run: make downstream-test-molecule - working-directory: ./ansible_collections/community/kubernetes + working-directory: ./ansible_collections/kubernetes/core diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0fcae83f..ed93b78c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,16 +9,16 @@ https://docs.ansible.com/ansible/latest/community/index.html). ## Kubernetes Collections -### community.kubernetes +### kubernetes.core This collection contains modules and plugins contributed and maintained by the Ansible Kubernetes community. -New modules and plugins developed by the community should be proposed to `community.kubernetes`. +New modules and plugins developed by the community should be proposed to `kubernetes.core`. ## Submitting Issues -All software has bugs, and the `community.kubernetes` collection is no exception. When you find a bug, -you can help tremendously by [telling us about it](https://github.com/ansible-collections/community.kubernetes/issues/new/choose). +All software has bugs, and the `kubernetes.core` collection is no exception. When you find a bug, +you can help tremendously by [telling us about it](https://github.com/ansible-collections/kubernetes.core/issues/new/choose). If you should discover that the bug you're trying to file already exists in an issue, you can help by verifying the behavior of the reported bug with a comment in that @@ -28,7 +28,7 @@ issue, or by reporting any additional information. All modules MUST have integration tests for new features. Bug fixes for modules that currently have integration tests SHOULD have tests added. -New modules should be submitted to the [community.kubernetes](https://github.com/ansible-collections/community.kubernetes) collection and MUST have integration tests. +New modules should be submitted to the [kubernetes.core](https://github.com/ansible-collections/kubernetes.core) collection and MUST have integration tests. Expected test criteria: * Resource creation under check mode @@ -52,7 +52,7 @@ especially the section on configuration for cloud tests. For questions about wri ### Code of Conduct -The `community.kubernetes` collection follows the Ansible project's +The `kubernetes.core` collection follows the Ansible project's [Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). Please read and familiarize yourself with this document. @@ -60,6 +60,6 @@ Please read and familiarize yourself with this document. Our IRC channels may require you to register your nickname. If you receive an error when you connect, see [Freenode's Nickname Registration guide](https://freenode.net/kb/answer/registration) for instructions. -The `#ansible-kubernetes` channel on Freenode IRC is the main and official place to discuss use and development of the `community.kubernetes` collection. +The `#ansible-kubernetes` channel on Freenode IRC is the main and official place to discuss use and development of the `kubernetes.core` collection. For more information about Ansible's Kubernetes integration, browse the resources in the [Kubernetes Working Group](https://github.com/ansible/community/wiki/Kubernetes) Community wiki page. diff --git a/Makefile b/Makefile index 6efb6b7c..5bd6613e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ TEST_ARGS ?= "" PYTHON_VERSION ?= `python -c 'import platform; print("{0}.{1}".format(platform.python_version_tuple()[0], platform.python_version_tuple()[1]))'` clean: - rm -f community-kubernetes-${VERSION}.tar.gz + rm -f kubernetes-core-${VERSION}.tar.gz rm -rf ansible_collections rm -rf tests/output @@ -13,10 +13,10 @@ build: clean ansible-galaxy collection build release: build - ansible-galaxy collection publish community-kubernetes-${VERSION}.tar.gz + ansible-galaxy collection publish kubernetes-core-${VERSION}.tar.gz install: build - ansible-galaxy collection install -p ansible_collections community-kubernetes-${VERSION}.tar.gz + ansible-galaxy collection install -p ansible_collections kubernetes-core-${VERSION}.tar.gz test-sanity: ansible-test sanity --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) @@ -29,18 +29,3 @@ test-molecule: test-unit: ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) - -downstream-test-sanity: - ./utils/downstream.sh -s - -downstream-test-integration: - ./utils/downstream.sh -i - -downstream-test-molecule: - ./utils/downstream.sh -m - -downstream-build: - ./utils/downstream.sh -b - -downstream-release: - ./utils/downstream.sh -r diff --git a/README.md b/README.md index 51e009f1..ea9428a7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Kubernetes Collection for Ansible -[![CI](https://github.com/ansible-collections/community.kubernetes/workflows/CI/badge.svg?event=push)](https://github.com/ansible-collections/community.kubernetes/actions) [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.kubernetes)](https://codecov.io/gh/ansible-collections/community.kubernetes) +[![CI](https://github.com/ansible-collections/kubernetes.core/workflows/CI/badge.svg?event=push)](https://github.com/ansible-collections/kubernetes.core/actions) [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/kubernetes.core)](https://codecov.io/gh/ansible-collections/kubernetes.core) -This repo hosts the `community.kubernetes` (a.k.a. `kubernetes.core`) Ansible Collection. +This repo hosts the `kubernetes.core` (formerly known as `community.kubernetes`) Ansible Collection. The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves. @@ -21,7 +21,7 @@ Click on the name of a plugin or module to view that content's documentation: - [k8s](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_lookup.html) - **Modules**: - [k8s](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_module.html) - - [k8s_cluster_info](https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/k8s_cluster_info.py) + - [k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/k8s_cluster_info.py) - [k8s_exec](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_exec_module.html) - [k8s_info](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_info_module.html) - [k8s_log](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_log_module.html) @@ -29,10 +29,10 @@ Click on the name of a plugin or module to view that content's documentation: - [k8s_service](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_service_module.html) - [helm](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_module.html) - [helm_info](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_info_module.html) - - [helm_plugin](https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/helm_plugin.py) - - [helm_plugin_info](https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/helm_plugin_info.py) + - [helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_plugin.py) + - [helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_plugin_info.py) - [helm_repository](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_repository_module.html) - - [helm_template](https://github.com/ansible-collections/community.kubernetes/blob/main/plugins/modules/helm_template.py) + - [helm_template](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_template.py) ## Installation and Usage @@ -40,14 +40,14 @@ Click on the name of a plugin or module to view that content's documentation: Before using the Kubernetes collection, you need to install it with the Ansible Galaxy CLI: - ansible-galaxy collection install community.kubernetes + ansible-galaxy collection install kubernetes.core You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format: ```yaml --- collections: - - name: community.kubernetes + - name: kubernetes.core version: 1.2.0 ``` @@ -59,7 +59,7 @@ Content in this collection requires the [OpenShift Python client](https://pypi.o ### Using modules from the Kubernetes Collection in your playbooks -It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `community.kubernetes.k8s_info`: +It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`: ```yaml --- @@ -69,14 +69,14 @@ It's preferable to use content in this collection using their Fully Qualified Co tasks: - name: Ensure the myapp Namespace exists. - community.kubernetes.k8s: + kubernetes.core.k8s: api_version: v1 kind: Namespace name: myapp state: present - name: Ensure the myapp Service exists in the myapp Namespace. - community.kubernetes.k8s: + kubernetes.core.k8s: state: present definition: apiVersion: v1 @@ -93,7 +93,7 @@ It's preferable to use content in this collection using their Fully Qualified Co app: myapp - name: Get a list of all Services in the myapp namespace. - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Service namespace: myapp register: myapp_services @@ -112,7 +112,7 @@ If upgrading older playbooks which were built prior to Ansible 2.10 and this col connection: local collections: - - community.kubernetes + - kubernetes.core tasks: - name: Ensure the myapp Namespace exists. @@ -129,7 +129,7 @@ For documentation on how to use individual modules and other content included in If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it into one of the configured [`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths), and work on it there. -See [Contributing to community.kubernetes](CONTRIBUTING.md). +See [Contributing to kubernetes.core](CONTRIBUTING.md). ### Testing with `ansible-test` @@ -139,6 +139,7 @@ You can run the collection's test suites with the commands: make test-sanity make test-integration + make test-unit ### Testing with `molecule` @@ -154,26 +155,16 @@ Releases are automatically built and pushed to Ansible Galaxy for any new tag. B 1. Update the version in the following places: 1. The `version` in `galaxy.yml` 2. This README's `requirements.yml` example - 3. The `DOWNSTREAM_VERSION` in `utils/downstream.sh` - 4. The `VERSION` in `Makefile` + 3. The `VERSION` in `Makefile` 2. Update the CHANGELOG: 1. Make sure you have [`antsibull-changelog`](https://pypi.org/project/antsibull-changelog/) installed. 2. Make sure there are fragments for all known changes in `changelogs/fragments`. 3. Run `antsibull-changelog release`. 3. Commit the changes and create a PR with the changes. Wait for tests to pass, then merge it once they have. 4. Tag the version in Git and push to GitHub. - 5. Manually build and release the `kubernetes.core` collection (see following section). After the version is published, verify it exists on the [Kubernetes Collection Galaxy page](https://galaxy.ansible.com/community/kubernetes). -### Publishing `kubernetes.core` - -Until the contents of repository are moved into a new `kubernetes.core` repository on GitHub, this repository is the source of both the `kubernetes.core` and `community.kubernetes` repositories on Ansible Galaxy. - -To publish the `kubernetes.core` collection on Ansible Galaxy, do the following: - - 1. Run `make downstream-release` (on macOS, add `LC_ALL=C` before the command). - The process for uploading a supported release to Automation Hub is documented separately. ## More Information diff --git a/galaxy.yml b/galaxy.yml index 9236d149..52fd8541 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -12,12 +12,12 @@ dependencies: {} description: Kubernetes Collection for Ansible. documentation: '' homepage: '' -issues: https://github.com/ansible-collections/community.kubernetes/issues +issues: https://github.com/ansible-collections/kubernetes.core/issues license_file: LICENSE -name: kubernetes -namespace: community +name: core +namespace: kubernetes readme: README.md -repository: https://github.com/ansible-collections/community.kubernetes +repository: https://github.com/ansible-collections/kubernetes.core tags: - kubernetes - k8s diff --git a/meta/runtime.yml b/meta/runtime.yml index 9f7fee5d..27cc1a89 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -18,31 +18,31 @@ action_groups: plugin_routing: action: helm: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info helm_info: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info helm_plugin: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info helm_plugin_info: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info helm_repository: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_cluster_info: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_event_info: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_exec: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_log: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_rollback: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_scale: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info k8s_service: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info inventory: openshift: redirect: community.okd.openshift @@ -51,24 +51,24 @@ plugin_routing: redirect: community.okd.k8s_auth # k8s_facts was originally slated for removal in Ansible 2.13. k8s_facts: - redirect: community.kubernetes.k8s_info + redirect: kubernetes.core.k8s_info deprecation: removal_version: 2.0.0 - warning_text: Use community.kubernetes.k8s_info instead. + warning_text: Use kubernetes.core.k8s_info instead. k8s_raw: tombstone: removal_version: 0.1.0 - warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use community.kubernetes.k8s instead. + warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. openshift_raw: tombstone: removal_version: 0.1.0 - warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use community.kubernetes.k8s instead. + warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. openshift_scale: tombstone: removal_version: 0.1.0 - warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use community.kubernetes.k8s_scale instead. + warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead. lookup: openshift: tombstone: removal_version: 0.1.0 - warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use community.kubernetes.k8s instead. + warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 22fd2b7e..076cbc16 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,7 +4,7 @@ connection: local collections: - - community.kubernetes + - kubernetes.core vars_files: - vars/main.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 693cd351..15895965 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -17,11 +17,11 @@ provisioner: log: true config_options: inventory: - enable_plugins: community.kubernetes.k8s + enable_plugins: kubernetes.core.k8s lint: {} inventory: hosts: - plugin: community.kubernetes.k8s + plugin: kubernetes.core.k8s host_vars: localhost: ansible_python_interpreter: '{{ ansible_playbook_python }}' diff --git a/molecule/default/tasks/template.yml b/molecule/default/tasks/template.yml index 4d76d799..3e18b3bb 100644 --- a/molecule/default/tasks/template.yml +++ b/molecule/default/tasks/template.yml @@ -12,7 +12,7 @@ name: "{{ template_namespace }}" - name: Check if k8s_service does not inherit parameter - community.kubernetes.k8s_service: + kubernetes.core.k8s_service: template: "pod_template_one.j2" state: present ignore_errors: yes @@ -25,7 +25,7 @@ - "'is only supported parameter for' in r.msg" - name: Specify both definition and template - community.kubernetes.k8s: + kubernetes.core.k8s: state: present template: "pod_template_one.j2" definition: @@ -52,7 +52,7 @@ - "'parameters are mutually exclusive' in r.msg" - name: Specify both src and template - community.kubernetes.k8s: + kubernetes.core.k8s: state: present src: "../templates/pod_template_one.j2" template: "pod_template_one.j2" @@ -69,7 +69,7 @@ - "'parameters are mutually exclusive' in r.msg" - name: Create pod using template (direct specification) - community.kubernetes.k8s: + kubernetes.core.k8s: template: "pod_template_one.j2" wait: yes vars: @@ -83,7 +83,7 @@ - r is successful - name: Create pod using template with wrong parameter - community.kubernetes.k8s: + kubernetes.core.k8s: template: - default wait: yes @@ -100,7 +100,7 @@ - "'Error while reading template file' in r.msg" - name: Create pod using template (path parameter) - community.kubernetes.k8s: + kubernetes.core.k8s: template: path: "pod_template_one.j2" wait: yes @@ -115,7 +115,7 @@ - r is successful - name: Create pod using template (different variable string) - community.kubernetes.k8s: + kubernetes.core.k8s: template: path: "pod_template_two.j2" variable_start_string: '[[' @@ -133,7 +133,7 @@ - r is successful - name: Create pods using multi-resource template - community.kubernetes.k8s: + kubernetes.core.k8s: template: path: "pod_template_three.j2" wait: yes diff --git a/plugins/action/k8s_info.py b/plugins/action/k8s_info.py index f2cc4774..41ccf265 100644 --- a/plugins/action/k8s_info.py +++ b/plugins/action/k8s_info.py @@ -66,7 +66,7 @@ class ActionModule(ActionBase): def load_template(self, template, new_module_args, task_vars): # template is only supported by k8s module. - if self._task.action not in ('k8s', 'community.kubernetes.k8s', 'community.okd.k8s'): + if self._task.action not in ('k8s', 'kubernetes.core.k8s', 'community.okd.k8s'): raise AnsibleActionFail("'template' is only supported parameter for 'k8s' module.") if isinstance(template, string_types): # treat this as raw_params diff --git a/plugins/inventory/k8s.py b/plugins/inventory/k8s.py index cc106fce..b12f8512 100644 --- a/plugins/inventory/k8s.py +++ b/plugins/inventory/k8s.py @@ -23,7 +23,7 @@ DOCUMENTATION = ''' plugin: description: token that ensures this is a source file for the 'k8s' plugin. required: True - choices: ['community.kubernetes.k8s', 'k8s'] + choices: ['kubernetes.core.k8s', 'k8s'] connections: description: - Optional list of cluster connection settings. If no connections are provided, the default @@ -95,20 +95,20 @@ EXAMPLES = ''' # File must be named k8s.yaml or k8s.yml # Authenticate with token, and return all pods and services for all namespaces -plugin: community.kubernetes.k8s +plugin: kubernetes.core.k8s connections: - host: https://192.168.64.4:8443 api_key: xxxxxxxxxxxxxxxx validate_certs: false # Use default config (~/.kube/config) file and active context, and return objects for a specific namespace -plugin: community.kubernetes.k8s +plugin: kubernetes.core.k8s connections: - namespaces: - testing # Use a custom config file, and a specific context. -plugin: community.kubernetes.k8s +plugin: kubernetes.core.k8s connections: - kubeconfig: /path/to/config context: 'awx/192-168-64-4:8443/developer' @@ -117,7 +117,7 @@ connections: import json from ansible.errors import AnsibleError -from ansible_collections.community.kubernetes.plugins.module_utils.common import K8sAnsibleMixin, HAS_K8S_MODULE_HELPER, k8s_import_exception, get_api_client +from ansible_collections.kubernetes.core.plugins.module_utils.common import K8sAnsibleMixin, HAS_K8S_MODULE_HELPER, k8s_import_exception, get_api_client from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable try: @@ -142,9 +142,9 @@ class K8sInventoryException(Exception): class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable, K8sAnsibleMixin): - NAME = 'community.kubernetes.k8s' + NAME = 'kubernetes.core.k8s' - connection_plugin = 'community.kubernetes.kubectl' + connection_plugin = 'kubernetes.core.kubectl' transport = 'kubectl' def parse(self, inventory, loader, path, cache=True): diff --git a/plugins/lookup/k8s.py b/plugins/lookup/k8s.py index fc4558cf..7bfd1b79 100644 --- a/plugins/lookup/k8s.py +++ b/plugins/lookup/k8s.py @@ -133,23 +133,23 @@ DOCUMENTATION = ''' EXAMPLES = """ - name: Fetch a list of namespaces set_fact: - projects: "{{ lookup('community.kubernetes.k8s', api_version='v1', kind='Namespace') }}" + projects: "{{ lookup('kubernetes.core.k8s', api_version='v1', kind='Namespace') }}" - name: Fetch all deployments set_fact: - deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment') }}" + deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment') }}" - name: Fetch all deployments in a namespace set_fact: - deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment', namespace='testing') }}" + deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing') }}" - name: Fetch a specific deployment by name set_fact: - deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}" + deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}" - name: Fetch with label selector set_fact: - service: "{{ lookup('community.kubernetes.k8s', kind='Service', label_selector='app=galaxy') }}" + service: "{{ lookup('kubernetes.core.k8s', kind='Service', label_selector='app=galaxy') }}" # Use parameters from a YAML config @@ -159,11 +159,11 @@ EXAMPLES = """ - name: Using the config (loaded from a file in prior task), fetch the latest version of the object set_fact: - service: "{{ lookup('community.kubernetes.k8s', resource_definition=config) }}" + service: "{{ lookup('kubernetes.core.k8s', resource_definition=config) }}" - name: Use a config from the local filesystem set_fact: - service: "{{ lookup('community.kubernetes.k8s', src='service.yml') }}" + service: "{{ lookup('kubernetes.core.k8s', src='service.yml') }}" """ RETURN = """ @@ -198,7 +198,7 @@ from ansible.errors import AnsibleError from ansible.module_utils.common._collections_compat import KeysView from ansible.plugins.lookup import LookupBase -from ansible_collections.community.kubernetes.plugins.module_utils.common import K8sAnsibleMixin, get_api_client +from ansible_collections.kubernetes.core.plugins.module_utils.common import K8sAnsibleMixin, get_api_client try: diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index 40e9564e..b4630afe 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -26,7 +26,7 @@ import sys from datetime import datetime from distutils.version import LooseVersion -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import (AUTH_ARG_MAP, AUTH_ARG_SPEC) +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_MAP, AUTH_ARG_SPEC) from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.six import iteritems, string_types diff --git a/plugins/modules/helm.py b/plugins/modules/helm.py index 2a93a2ed..489e9ace 100644 --- a/plugins/modules/helm.py +++ b/plugins/modules/helm.py @@ -140,12 +140,12 @@ options: default: False version_added: "1.2.0" extends_documentation_fragment: - - community.kubernetes.helm_common_options + - kubernetes.core.helm_common_options ''' EXAMPLES = r''' - name: Deploy latest version of Prometheus chart inside monitoring namespace (and create it) - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: stable/prometheus release_namespace: monitoring @@ -153,12 +153,12 @@ EXAMPLES = r''' # From repository - name: Add stable chart repo - community.kubernetes.helm_repository: + kubernetes.core.helm_repository: name: stable repo_url: "https://kubernetes.github.io/ingress-nginx" - name: Deploy latest version of Grafana chart inside monitoring namespace with values - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: stable/grafana release_namespace: monitoring @@ -166,14 +166,14 @@ EXAMPLES = r''' replicas: 2 - name: Deploy Grafana chart on 5.0.12 with values loaded from template - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: stable/grafana chart_version: 5.0.12 values: "{{ lookup('template', 'somefile.yaml') | from_yaml }}" - name: Deploy Grafana chart using values files on target - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: stable/grafana release_namespace: monitoring @@ -181,7 +181,7 @@ EXAMPLES = r''' - /path/to/values.yaml - name: Remove test release and waiting suppression ending - community.kubernetes.helm: + kubernetes.core.helm: name: test state: absent wait: true @@ -193,14 +193,14 @@ EXAMPLES = r''' dest: /tmp/helm_repo - name: Deploy Grafana chart from local path - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: /tmp/helm_repo/stable/grafana release_namespace: monitoring # From url - name: Deploy Grafana chart on 5.6.0 from url - community.kubernetes.helm: + kubernetes.core.helm: name: test chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz" release_namespace: monitoring @@ -272,7 +272,7 @@ except ImportError: IMP_YAML = False from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm, get_values +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm, get_values def get_release(state, release_name): diff --git a/plugins/modules/helm_info.py b/plugins/modules/helm_info.py index 0f649fe1..e4ccf6cc 100644 --- a/plugins/modules/helm_info.py +++ b/plugins/modules/helm_info.py @@ -39,12 +39,12 @@ options: type: str aliases: [ namespace ] extends_documentation_fragment: - - community.kubernetes.helm_common_options + - kubernetes.core.helm_common_options ''' EXAMPLES = r''' - name: Deploy latest version of Grafana chart inside monitoring namespace - community.kubernetes.helm_info: + kubernetes.core.helm_info: name: test release_namespace: monitoring ''' @@ -99,7 +99,7 @@ except ImportError: IMP_YAML = False from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm, get_values +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm, get_values # Get Release from all deployed releases diff --git a/plugins/modules/helm_plugin.py b/plugins/modules/helm_plugin.py index d13f039b..430f91f2 100644 --- a/plugins/modules/helm_plugin.py +++ b/plugins/modules/helm_plugin.py @@ -47,22 +47,22 @@ options: - Required only if C(state=present). type: str extends_documentation_fragment: - - community.kubernetes.helm_common_options + - kubernetes.core.helm_common_options ''' EXAMPLES = r''' - name: Install Helm env plugin - community.kubernetes.helm_plugin: + kubernetes.core.helm_plugin: plugin_path: https://github.com/adamreese/helm-env state: present - name: Install Helm plugin from local filesystem - community.kubernetes.helm_plugin: + kubernetes.core.helm_plugin: plugin_path: https://domain/path/to/plugin.tar.gz state: present - name: Remove Helm env plugin - community.kubernetes.helm_plugin: + kubernetes.core.helm_plugin: plugin_name: env state: absent ''' @@ -96,7 +96,7 @@ rc: ''' from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm def main(): diff --git a/plugins/modules/helm_plugin_info.py b/plugins/modules/helm_plugin_info.py index 8b551838..db46d64d 100644 --- a/plugins/modules/helm_plugin_info.py +++ b/plugins/modules/helm_plugin_info.py @@ -32,15 +32,15 @@ options: - Name of Helm plugin, to gather particular plugin info. type: str extends_documentation_fragment: - - community.kubernetes.helm_common_options + - kubernetes.core.helm_common_options ''' EXAMPLES = r''' - name: Gather Helm plugin info - community.kubernetes.helm_plugin_info: + kubernetes.core.helm_plugin_info: - name: Gather Helm env plugin info - community.kubernetes.helm_plugin_info: + kubernetes.core.helm_plugin_info: plugin_name: env ''' @@ -77,7 +77,7 @@ rc: ''' from ansible.module_utils.basic import AnsibleModule, env_fallback -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm def main(): diff --git a/plugins/modules/helm_repository.py b/plugins/modules/helm_repository.py index bb0eccc3..f125209a 100644 --- a/plugins/modules/helm_repository.py +++ b/plugins/modules/helm_repository.py @@ -68,12 +68,12 @@ options: EXAMPLES = r''' - name: Add a repository - community.kubernetes.helm_repository: + kubernetes.core.helm_repository: name: stable repo_url: https://kubernetes.github.io/ingress-nginx - name: Add Red Hat Helm charts repository - community.kubernetes.helm_repository: + kubernetes.core.helm_repository: name: redhat-charts repo_url: https://redhat-developer.github.com/redhat-helm-charts ''' @@ -121,7 +121,7 @@ except ImportError: IMP_YAML = False from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm # Get repository from all repositories added diff --git a/plugins/modules/helm_template.py b/plugins/modules/helm_template.py index 0a699f48..6135dfb3 100644 --- a/plugins/modules/helm_template.py +++ b/plugins/modules/helm_template.py @@ -83,12 +83,12 @@ options: EXAMPLES = r''' - name: Render templates to specified directory - community.kubernetes.helm_template: + kubernetes.core.helm_template: chart_ref: stable/prometheus output_dir: mycharts - name: Render templates - community.kubernetes.helm_template: + kubernetes.core.helm_template: chart_ref: stable/prometheus register: result @@ -127,7 +127,7 @@ except ImportError: IMP_YAML = False from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm +from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm def template(cmd, chart_ref, chart_repo_url=None, chart_version=None, output_dir=None, diff --git a/plugins/modules/k8s.py b/plugins/modules/k8s.py index 4baefa14..24883d04 100644 --- a/plugins/modules/k8s.py +++ b/plugins/modules/k8s.py @@ -24,17 +24,17 @@ description: - Pass the object definition from a source file or inline. See examples for reading files and using Jinja templates or vault-encrypted files. - Access to the full range of K8s APIs. - - Use the M(community.kubernetes.k8s_info) module to obtain a list of items about an object of type C(kind) + - Use the M(kubernetes.core.k8s_info) module to obtain a list of items about an object of type C(kind) - Authenticate using either a config file, certificates, password or token. - Supports check mode. extends_documentation_fragment: - - community.kubernetes.k8s_state_options - - community.kubernetes.k8s_name_options - - community.kubernetes.k8s_resource_options - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_wait_options - - community.kubernetes.k8s_delete_options + - kubernetes.core.k8s_state_options + - kubernetes.core.k8s_name_options + - kubernetes.core.k8s_resource_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_wait_options + - kubernetes.core.k8s_delete_options notes: - If your OpenShift Python library is not 0.9.0 or newer and you are trying to @@ -132,14 +132,14 @@ requirements: EXAMPLES = r''' - name: Create a k8s namespace - community.kubernetes.k8s: + kubernetes.core.k8s: name: testing api_version: v1 kind: Namespace state: present - name: Create a Service object from an inline definition - community.kubernetes.k8s: + kubernetes.core.k8s: state: present definition: apiVersion: v1 @@ -161,7 +161,7 @@ EXAMPLES = r''' port: 8000 - name: Remove an existing Service object - community.kubernetes.k8s: + kubernetes.core.k8s: state: absent api_version: v1 kind: Service @@ -171,24 +171,24 @@ EXAMPLES = r''' # Passing the object definition from a file - name: Create a Deployment by reading the definition from a local file - community.kubernetes.k8s: + kubernetes.core.k8s: state: present src: /testing/deployment.yml - name: >- Read definition file from the Ansible controller file system. If the definition file has been encrypted with Ansible Vault it will automatically be decrypted. - community.kubernetes.k8s: + kubernetes.core.k8s: state: present definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}" - name: Read definition template file from the Ansible controller file system - community.kubernetes.k8s: + kubernetes.core.k8s: state: present template: '/testing/deployment.j2' - name: Read definition template file from the Ansible controller file system that uses custom start/end strings - community.kubernetes.k8s: + kubernetes.core.k8s: state: present template: path: '/testing/deployment.j2' @@ -196,14 +196,14 @@ EXAMPLES = r''' variable_end_string: ']]' - name: fail on validation errors - community.kubernetes.k8s: + kubernetes.core.k8s: state: present definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}" validate: fail_on_error: yes - name: warn on validation errors, check for unexpected properties - community.kubernetes.k8s: + kubernetes.core.k8s: state: present definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}" validate: @@ -218,13 +218,13 @@ EXAMPLES = r''' mode: '0664' - name: Apply metrics-server manifest to the cluster. - community.kubernetes.k8s: + kubernetes.core.k8s: state: present src: ~/metrics-server.yaml # Wait for a Deployment to pause before continuing - name: Pause a Deployment. - community.kubernetes.k8s: + kubernetes.core.k8s: definition: apiVersion: apps/v1 kind: Deployment @@ -280,8 +280,8 @@ result: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( AUTH_ARG_SPEC, WAIT_ARG_SPEC, NAME_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC, DELETE_OPTS_ARG_SPEC) @@ -336,7 +336,7 @@ def main(): ('template', 'src'), ] module = AnsibleModule(argument_spec=argspec(), mutually_exclusive=mutually_exclusive, supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/plugins/modules/k8s_cluster_info.py b/plugins/modules/k8s_cluster_info.py index 40e9e09e..242757cf 100644 --- a/plugins/modules/k8s_cluster_info.py +++ b/plugins/modules/k8s_cluster_info.py @@ -30,7 +30,7 @@ options: default: True extends_documentation_fragment: - - community.kubernetes.k8s_auth_options + - kubernetes.core.k8s_auth_options requirements: - "python >= 2.7" @@ -40,11 +40,11 @@ requirements: EXAMPLES = r''' - name: Get Cluster information - community.kubernetes.k8s_cluster_info: + kubernetes.core.k8s_cluster_info: register: api_status - name: Do not invalidate cache before getting information - community.kubernetes.k8s_cluster_info: + kubernetes.core.k8s_cluster_info: invalidate_cache: False register: api_status ''' @@ -160,9 +160,9 @@ apis: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule from ansible.module_utils.parsing.convert_bool import boolean -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import (AUTH_ARG_SPEC) +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_SPEC) def execute_module(module, client): @@ -211,7 +211,7 @@ def argspec(): def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import get_api_client + from ansible_collections.kubernetes.core.plugins.module_utils.common import get_api_client execute_module(module, client=get_api_client(module=module)) diff --git a/plugins/modules/k8s_exec.py b/plugins/modules/k8s_exec.py index 55e60849..256d0384 100644 --- a/plugins/modules/k8s_exec.py +++ b/plugins/modules/k8s_exec.py @@ -23,7 +23,7 @@ description: - Use the Kubernetes Python client to execute command on K8s pods. extends_documentation_fragment: - - community.kubernetes.k8s_auth_options + - kubernetes.core.k8s_auth_options requirements: - "python >= 2.7" @@ -66,13 +66,13 @@ options: EXAMPLES = r''' - name: Execute a command - community.kubernetes.k8s_exec: + kubernetes.core.k8s_exec: namespace: myproject pod: zuul-scheduler command: zuul-scheduler full-reconfigure - name: Check RC status of command executed - community.kubernetes.k8s_exec: + kubernetes.core.k8s_exec: namespace: myproject pod: busybox-test command: cmd_with_non_zero_exit_code @@ -118,9 +118,9 @@ except ImportError: # ImportError are managed by the common module already. pass -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule from ansible.module_utils._text import to_native -from ansible_collections.community.kubernetes.plugins.module_utils.common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.common import ( AUTH_ARG_SPEC ) @@ -192,7 +192,7 @@ def main(): argument_spec=argspec(), supports_check_mode=True, ) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/plugins/modules/k8s_info.py b/plugins/modules/k8s_info.py index 0119d61e..28c639a6 100644 --- a/plugins/modules/k8s_info.py +++ b/plugins/modules/k8s_info.py @@ -44,9 +44,9 @@ options: elements: str extends_documentation_fragment: - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_name_options - - community.kubernetes.k8s_wait_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_name_options + - kubernetes.core.k8s_wait_options requirements: - "python >= 2.7" @@ -56,7 +56,7 @@ requirements: EXAMPLES = r''' - name: Get an existing Service object - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: api_version: v1 kind: Service name: web @@ -64,26 +64,26 @@ EXAMPLES = r''' register: web_service - name: Get a list of all service objects - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: api_version: v1 kind: Service namespace: testing register: service_list - name: Get a list of all pods from any namespace - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Pod register: pod_list - name: Search for all Pods labelled app=web - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Pod label_selectors: - app = web - tier in (dev, test) - name: Using vars while using label_selectors - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Pod label_selectors: - "app = {{ app_label_web }}" @@ -91,18 +91,18 @@ EXAMPLES = r''' app_label_web: web - name: Search for all running pods - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Pod field_selectors: - status.phase=Running - name: List custom objects created using CRD - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: MyCustomObject api_version: "stable.example.com/v1" - name: Wait till the Object is created - community.kubernetes.k8s_info: + kubernetes.core.k8s_info: kind: Pod wait: yes name: pod-not-yet-created @@ -148,8 +148,8 @@ resources: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import (AUTH_ARG_SPEC, WAIT_ARG_SPEC) +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_SPEC, WAIT_ARG_SPEC) def execute_module(module, k8s_ansible_mixin): @@ -186,7 +186,7 @@ def argspec(): def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/plugins/modules/k8s_log.py b/plugins/modules/k8s_log.py index 50b568b4..071d64db 100644 --- a/plugins/modules/k8s_log.py +++ b/plugins/modules/k8s_log.py @@ -25,8 +25,8 @@ description: - Supports check mode. - Analogous to `kubectl logs` or `oc logs` extends_documentation_fragment: - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_name_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_name_options options: kind: description: @@ -63,14 +63,14 @@ requirements: EXAMPLES = r''' - name: Get a log from a Pod - community.kubernetes.k8s_log: + kubernetes.core.k8s_log: name: example-1 namespace: testing register: log # This will get the log from the first Pod found matching the selector - name: Log a Pod matching a label selector - community.kubernetes.k8s_log: + kubernetes.core.k8s_log: namespace: testing label_selectors: - app=example @@ -78,7 +78,7 @@ EXAMPLES = r''' # This will get the log from a single Pod managed by this Deployment - name: Get a log from a Deployment - community.kubernetes.k8s_log: + kubernetes.core.k8s_log: api_version: apps/v1 kind: Deployment namespace: testing @@ -87,7 +87,7 @@ EXAMPLES = r''' # This will get the log from a single Pod managed by this DeploymentConfig - name: Get a log from a DeploymentConfig - community.kubernetes.k8s_log: + kubernetes.core.k8s_log: api_version: apps.openshift.io/v1 kind: DeploymentConfig namespace: testing @@ -111,10 +111,10 @@ log_lines: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule from ansible.module_utils.six import PY2 -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import (AUTH_ARG_SPEC, NAME_ARG_SPEC) +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (AUTH_ARG_SPEC, NAME_ARG_SPEC) def argspec(): @@ -215,7 +215,7 @@ def serialize_log(response): def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/plugins/modules/k8s_rollback.py b/plugins/modules/k8s_rollback.py index 20465b44..e41da810 100644 --- a/plugins/modules/k8s_rollback.py +++ b/plugins/modules/k8s_rollback.py @@ -28,8 +28,8 @@ options: type: list elements: str extends_documentation_fragment: - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_name_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_name_options requirements: - "python >= 2.7" - "openshift >= 0.6" @@ -38,7 +38,7 @@ requirements: EXAMPLES = r''' - name: Rollback a failed deployment - community.kubernetes.k8s_rollback: + kubernetes.core.k8s_rollback: api_version: apps/v1 kind: Deployment name: web @@ -78,8 +78,8 @@ rollback_info: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( AUTH_ARG_SPEC, NAME_ARG_SPEC) @@ -208,7 +208,7 @@ def get_previous_revision(all_resources, current_revision): def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import (K8sAnsibleMixin, get_api_client) + from ansible_collections.kubernetes.core.plugins.module_utils.common import (K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) k8s_ansible_mixin.client = get_api_client(module=module) diff --git a/plugins/modules/k8s_scale.py b/plugins/modules/k8s_scale.py index c15bd5e0..149df21f 100644 --- a/plugins/modules/k8s_scale.py +++ b/plugins/modules/k8s_scale.py @@ -25,10 +25,10 @@ description: or Replication Controller, or the parallelism attribute of a Job. Supports check mode. extends_documentation_fragment: - - community.kubernetes.k8s_name_options - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_resource_options - - community.kubernetes.k8s_scale_options + - kubernetes.core.k8s_name_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_resource_options + - kubernetes.core.k8s_scale_options requirements: - "python >= 2.7" @@ -38,7 +38,7 @@ requirements: EXAMPLES = r''' - name: Scale deployment up, and extend timeout - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: api_version: v1 kind: Deployment name: elastic @@ -47,7 +47,7 @@ EXAMPLES = r''' wait_timeout: 60 - name: Scale deployment down when current replicas match - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: api_version: v1 kind: Deployment name: elastic @@ -56,7 +56,7 @@ EXAMPLES = r''' replicas: 2 - name: Increase job parallelism - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: api_version: batch/v1 kind: job name: pi-with-timeout @@ -66,19 +66,19 @@ EXAMPLES = r''' # Match object using local file or inline definition - name: Scale deployment based on a file from the local filesystem - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: src: /myproject/elastic_deployment.yml replicas: 3 wait: no - name: Scale deployment based on a template output - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: resource_definition: "{{ lookup('template', '/myproject/elastic_deployment.yml') | from_yaml }}" replicas: 3 wait: no - name: Scale deployment based on a file from the Ansible controller filesystem - community.kubernetes.k8s_scale: + kubernetes.core.k8s_scale: resource_definition: "{{ lookup('file', '/myproject/elastic_deployment.yml') | from_yaml }}" replicas: 3 wait: no @@ -120,8 +120,8 @@ result: import copy -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC) @@ -157,7 +157,7 @@ def execute_module(module, k8s_ansible_mixin,): resource = k8s_ansible_mixin.find_resource(kind, api_version, fail=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import NotFoundError + from ansible_collections.kubernetes.core.plugins.module_utils.common import NotFoundError try: existing = resource.get(name=name, namespace=namespace) @@ -235,7 +235,7 @@ def scale(module, k8s_ansible_mixin, resource, existing_object, replicas, wait, def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/plugins/modules/k8s_service.py b/plugins/modules/k8s_service.py index 945df2d4..95a60ae2 100644 --- a/plugins/modules/k8s_service.py +++ b/plugins/modules/k8s_service.py @@ -21,9 +21,9 @@ description: - Use Openshift Python SDK to manage Services on Kubernetes extends_documentation_fragment: - - community.kubernetes.k8s_auth_options - - community.kubernetes.k8s_resource_options - - community.kubernetes.k8s_state_options + - kubernetes.core.k8s_auth_options + - kubernetes.core.k8s_resource_options + - kubernetes.core.k8s_state_options options: merge_type: @@ -91,7 +91,7 @@ requirements: EXAMPLES = r''' - name: Expose https port with ClusterIP - community.kubernetes.k8s_service: + kubernetes.core.k8s_service: state: present name: test-https namespace: default @@ -102,7 +102,7 @@ EXAMPLES = r''' key: special - name: Expose https port with ClusterIP using spec - community.kubernetes.k8s_service: + kubernetes.core.k8s_service: state: present name: test-https namespace: default @@ -148,8 +148,8 @@ import copy from collections import defaultdict -from ansible_collections.community.kubernetes.plugins.module_utils.ansiblemodule import AnsibleModule -from ansible_collections.community.kubernetes.plugins.module_utils.args_common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule +from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC) SERVICE_ARG_SPEC = { @@ -228,7 +228,7 @@ def execute_module(module, k8s_ansible_mixin): def main(): module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True) - from ansible_collections.community.kubernetes.plugins.module_utils.common import ( + from ansible_collections.kubernetes.core.plugins.module_utils.common import ( K8sAnsibleMixin, get_api_client) k8s_ansible_mixin = K8sAnsibleMixin(module) diff --git a/tests/unit/module_utils/test_common.py b/tests/unit/module_utils/test_common.py index 5eb4621b..9444da2d 100644 --- a/tests/unit/module_utils/test_common.py +++ b/tests/unit/module_utils/test_common.py @@ -7,7 +7,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.kubernetes.plugins.module_utils.common import ( +from ansible_collections.kubernetes.core.plugins.module_utils.common import ( _encode_stringdata, ) diff --git a/tests/unit/module_utils/test_helm.py b/tests/unit/module_utils/test_helm.py index 4100f7a6..9e498e3e 100644 --- a/tests/unit/module_utils/test_helm.py +++ b/tests/unit/module_utils/test_helm.py @@ -11,7 +11,7 @@ import os.path import yaml -from ansible_collections.community.kubernetes.plugins.module_utils.helm import ( +from ansible_collections.kubernetes.core.plugins.module_utils.helm import ( run_helm, write_temp_kubeconfig, ) diff --git a/utils/downstream.sh b/utils/downstream.sh deleted file mode 100755 index 6bfa7872..00000000 --- a/utils/downstream.sh +++ /dev/null @@ -1,227 +0,0 @@ -#!/bin/bash -eu - -# Script to dual-home the upstream and downstream Collection in a single repo -# -# This script will build or test a downstream collection, removing any -# upstream components that will not ship in the downstream release -# -# NOTES: -# - All functions are prefixed with f_ so it's obvious where they come -# from when in use throughout the script - -DOWNSTREAM_VERSION="1.2.0" -KEEP_DOWNSTREAM_TMPDIR="${KEEP_DOWNSTREAM_TMPDIR:-''}" - - -f_log_info() -{ - printf "%s:LOG:INFO: %s\n" "${0}" "${1}\n" -} - -f_prep() -{ - f_log_info "${FUNCNAME[0]}" - # Array of excluded files from downstream build (relative path) - _file_exclude=( - ) - - # Files to copy downstream (relative repo root dir path) - _file_manifest=( - CHANGELOG.rst - galaxy.yml - LICENSE - README.md - Makefile - setup.cfg - .yamllint - ) - - # Directories to recursively copy downstream (relative repo root dir path) - _dir_manifest=( - changelogs - meta - plugins - tests - molecule - ) - - # Temp build dir - _tmp_dir=$(mktemp -d) - _build_dir="${_tmp_dir}/ansible_collections/kubernetes/core" - mkdir -p "${_build_dir}" -} - -f_show_help() -{ - printf "Usage: downstream.sh [OPTION]\n" - printf "\t-s\t\tCreate a temporary downstream release and perform sanity tests.\n" - printf "\t-i\t\tCreate a temporary downstream release and perform integration tests.\n" - printf "\t-m\t\tCreate a temporary downstream release and perform molecule tests.\n" - printf "\t-b\t\tCreate a downstream release and stage for release.\n" - printf "\t-r\t\tCreate a downstream release and publish release.\n" -} - -f_text_sub() -{ - # Switch FQCN and dependent components - sed -i.bak "s/community-kubernetes/kubernetes-core/" "${_build_dir}/Makefile" - sed -i.bak "s/community\/kubernetes/kubernetes\/core/" "${_build_dir}/Makefile" - sed -i.bak "s/^VERSION\:/VERSION: ${DOWNSTREAM_VERSION}/" "${_build_dir}/Makefile" - sed -i.bak "s/community.kubernetes/kubernetes.core/" "${_build_dir}/galaxy.yml" - sed -i.bak "s/name\:.*$/name: core/" "${_build_dir}/galaxy.yml" - sed -i.bak "s/namespace\:.*$/namespace: kubernetes/" "${_build_dir}/galaxy.yml" - sed -i.bak "s/^version\:.*$/version: ${DOWNSTREAM_VERSION}/" "${_build_dir}/galaxy.yml" - find "${_build_dir}" -type f -exec sed -i.bak "s/community\.kubernetes/kubernetes\.core/g" {} \; - sed -i.bak "s/a\.k\.a\. \`kubernetes\.core\`/formerly known as \`community\.kubernetes\`/" "${_build_dir}/README.md"; - find "${_build_dir}" -type f -name "*.bak" -delete -} - -f_cleanup() -{ - f_log_info "${FUNCNAME[0]}" - if [[ -n ${KEEP_DOWNSTREAM_TMPDIR} ]]; then - if [[ -d ${_build_dir} ]]; then - rm -fr "${_build_dir}" - fi - fi -} - -# Exit and handle cleanup processes if needed -f_exit() -{ - f_cleanup - exit "$0" -} - -f_create_collection_dir_structure() -{ - f_log_info "${FUNCNAME[0]}" - # Create the Collection - for f_name in "${_file_manifest[@]}"; - do - cp "./${f_name}" "${_build_dir}/${f_name}" - done - for d_name in "${_dir_manifest[@]}"; - do - cp -r "./${d_name}" "${_build_dir}/${d_name}" - done - if [ -n "${_file_exclude:-}" ]; then - for exclude_file in "${_file_exclude[@]}"; - do - if [[ -f "${_build_dir}/${exclude_file}" ]]; then - rm -f "${_build_dir}/${exclude_file}" - fi - done - fi -} - -f_copy_collection_to_working_dir() -{ - f_log_info "${FUNCNAME[0]}" - # Copy the Collection build result into original working dir - cp "${_build_dir}"/*.tar.gz ./ -} - -f_common_steps() -{ - f_log_info "${FUNCNAME[0]}" - f_prep - f_create_collection_dir_structure - f_text_sub -} - -# Run the test sanity scanerio -f_test_sanity_option() -{ - f_log_info "${FUNCNAME[0]}" - f_common_steps - pushd "${_build_dir}" || return - f_log_info "SANITY TEST PWD: ${PWD}" - make test-sanity - popd || return - f_cleanup -} - -# Run the test integration -f_test_integration_option() -{ - f_log_info "${FUNCNAME[0]}" - f_common_steps - pushd "${_build_dir}" || return - f_log_info "INTEGRATION TEST WD: ${PWD}" - make test-integration - popd || return - f_cleanup -} - -# Run the molecule tests -f_test_molecule_option() -{ - f_log_info "${FUNCNAME[0]}" - f_common_steps - pushd "${_build_dir}" || return - f_log_info "MOLECULE TEST WD: ${PWD}" - make test-molecule - popd || return - f_cleanup -} - -# Run the release scanerio -f_release_option() -{ - f_log_info "${FUNCNAME[0]}" - f_common_steps - pushd "${_build_dir}" || return - f_log_info "RELEASE WD: ${PWD}" - make release - popd || return - f_cleanup -} - -# Run the build scanerio -f_build_option() -{ - f_log_info "${FUNCNAME[0]}" - f_common_steps - pushd "${_build_dir}" || return - f_log_info "BUILD WD: ${PWD}" - make build - popd || return - f_copy_collection_to_working_dir - f_cleanup -} - -# If no options are passed, display usage and exit -if [[ "${#}" -eq "0" ]]; then - f_show_help - f_exit 0 -fi - -# Handle options -while getopts ":simrb" option -do - case $option in - s) - f_test_sanity_option - ;; - i) - f_test_integration_option - ;; - m) - f_test_molecule_option - ;; - r) - f_release_option - ;; - b) - f_build_option - ;; - *) - printf "ERROR: Unimplemented option chosen.\n" - f_show_help - f_exit 1 - ;; # Default. - esac -done - -# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4