From 541717743609a7d65d86a03c77765b79f8f4eca0 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 20 Feb 2020 10:44:24 -0600 Subject: [PATCH] Fixes #33: Add missing args and docs for src and apply parameters in k8s_service.py. --- .gitignore | 1 + plugins/modules/k8s_service.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.gitignore b/.gitignore index d7e0b555..0460287a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.retry .idea *.log +__pycache__/ # Galaxy artifacts. *.tar.gz diff --git a/plugins/modules/k8s_service.py b/plugins/modules/k8s_service.py index b4d14429..b131c496 100644 --- a/plugins/modules/k8s_service.py +++ b/plugins/modules/k8s_service.py @@ -40,6 +40,15 @@ options: - definition - inline type: dict + src: + description: + - "Provide a path to a file containing a valid YAML definition of an object dated. Mutually + exclusive with I(resource_definition). NOTE: I(kind), I(api_version), I(resource_name), and I(namespace) + will be overwritten by corresponding values found in the configuration read in from the I(src) file." + - Reads from the local file system. To read from the Ansible controller's file system, use the file lookup + plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to + I(resource_definition). See Examples below. + type: path state: description: - Determines if an object should be created, patched, or deleted. When set to C(present), an object will be @@ -105,6 +114,14 @@ options: - Label selectors identify objects this Service should apply to. - U(https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) type: dict + apply: + description: + - C(apply) compares the desired resource definition with the previously supplied resource definition, + ignoring properties that are automatically generated + - C(apply) works better with Services than 'force=yes' + - mutually exclusive with C(merge_type) + type: bool + version_added: "2.9" requirements: - python >= 2.7 @@ -176,6 +193,10 @@ from ansible_collections.community.kubernetes.plugins.module_utils.raw import Ku SERVICE_ARG_SPEC = { + 'apply': { + 'type': 'bool', + 'default': False, + }, 'state': { 'default': 'present', 'choices': ['present', 'absent'], @@ -192,6 +213,9 @@ SERVICE_ARG_SPEC = { 'namespace': {'required': True}, 'merge_type': {'type': 'list', 'elements': 'str', 'choices': ['json', 'merge', 'strategic-merge']}, 'selector': {'type': 'dict'}, + 'src': { + 'type': 'path', + }, 'type': { 'type': 'str', 'choices': [