From b5de5357042c146a930097d52c3920808af89c42 Mon Sep 17 00:00:00 2001 From: Joel Diaz Date: Fri, 27 Jan 2017 20:39:06 +0000 Subject: oc_label ansible module used for adding/removing labels on various OpenShift objects --- roles/lib_openshift/src/doc/label | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 roles/lib_openshift/src/doc/label (limited to 'roles/lib_openshift/src/doc/label') diff --git a/roles/lib_openshift/src/doc/label b/roles/lib_openshift/src/doc/label new file mode 100644 index 000000000..8122bd4b0 --- /dev/null +++ b/roles/lib_openshift/src/doc/label @@ -0,0 +1,65 @@ +# flake8: noqa +# pylint: skip-file + +DOCUMENTATION = ''' +--- +module: oc_label +short_description: Create, modify, and idempotently manage openshift object labels. +description: + - Modify openshift labels programmatically. +options: + state: + description: + - State represents whether to create, modify, delete, or list + required: true + default: present + choices: ["present", "absent", "list", "add"] + aliases: [] + kubeconfig: + description: + - The path for the kubeconfig file to use for authentication + required: false + default: /etc/origin/master/admin.kubeconfig + aliases: [] + debug: + description: + - Turn on debug output. + required: false + default: False + aliases: [] + kind: + description: + - The kind of object that can be managed. + required: false + default: None + choices: + - node + - pod + aliases: [] + labels: + description: + - The labels to add to the resource. + required: false + default: None + aliases: [] + selector: + description: + - The selector to apply to the query + required: false + default: None + aliases: [] +author: +- "Joel Diaz " +extends_documentation_fragment: [] +''' + +EXAMPLES = ''' +- name: Add label to node + oc_label: + name: ip-172-31-5-23.ec2.internal + state: add + kind: node + labels: + - key: logging-infra-fluentd + value: 'true' +''' -- cgit v1.2.3 From 4806fe365e11a9a0266c06d052537836397a26c6 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Tue, 31 Jan 2017 09:36:23 -0500 Subject: Fixing doc and generating new label with updated base. --- roles/lib_openshift/src/doc/label | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'roles/lib_openshift/src/doc/label') diff --git a/roles/lib_openshift/src/doc/label b/roles/lib_openshift/src/doc/label index 8122bd4b0..1274d58c1 100644 --- a/roles/lib_openshift/src/doc/label +++ b/roles/lib_openshift/src/doc/label @@ -4,7 +4,7 @@ DOCUMENTATION = ''' --- module: oc_label -short_description: Create, modify, and idempotently manage openshift object labels. +short_description: Create, modify, and idempotently manage openshift labels. description: - Modify openshift labels programmatically. options: @@ -30,21 +30,22 @@ options: kind: description: - The kind of object that can be managed. - required: false + required: True default: None choices: - node - pod + - namespace aliases: [] labels: description: - - The labels to add to the resource. + - A list of labels to for the resource. required: false default: None aliases: [] selector: description: - - The selector to apply to the query + - The selector to apply to the resource query required: false default: None aliases: [] -- cgit v1.2.3 From 94fd71fa8fba70205519e18625975b83373c1535 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Tue, 31 Jan 2017 11:09:57 -0500 Subject: Adding unit test. Fixed redudant calls to get. --- roles/lib_openshift/src/doc/label | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'roles/lib_openshift/src/doc/label') diff --git a/roles/lib_openshift/src/doc/label b/roles/lib_openshift/src/doc/label index 1274d58c1..e206d0d06 100644 --- a/roles/lib_openshift/src/doc/label +++ b/roles/lib_openshift/src/doc/label @@ -11,7 +11,6 @@ options: state: description: - State represents whether to create, modify, delete, or list - required: true default: present choices: ["present", "absent", "list", "add"] aliases: [] @@ -30,8 +29,7 @@ options: kind: description: - The kind of object that can be managed. - required: True - default: None + default: node choices: - node - pod -- cgit v1.2.3 From 4b054d7da5f404dfd8eb238b617e4dcf7dc93b17 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 2 Feb 2017 22:21:23 -0500 Subject: Doc enhancements. --- roles/lib_openshift/src/doc/label | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'roles/lib_openshift/src/doc/label') diff --git a/roles/lib_openshift/src/doc/label b/roles/lib_openshift/src/doc/label index e206d0d06..fb3ed2503 100644 --- a/roles/lib_openshift/src/doc/label +++ b/roles/lib_openshift/src/doc/label @@ -10,7 +10,11 @@ description: options: state: description: - - State represents whether to create, modify, delete, or list + - State controls the action that will be taken with resource + - 'present' will create or update and object to the desired state + - 'absent' will ensure certain labels are removed + - 'list' will read the labels + - 'add' will insert labels to the already existing labels default: present choices: ["present", "absent", "list", "add"] aliases: [] @@ -37,7 +41,9 @@ options: aliases: [] labels: description: - - A list of labels to for the resource. + - A list of labels for the resource. + - Each list consists of a key and a value. + - eg, {'key': 'foo', 'value': 'bar'} required: false default: None aliases: [] @@ -53,7 +59,7 @@ extends_documentation_fragment: [] ''' EXAMPLES = ''' -- name: Add label to node +- name: Add a single label to a node's existing labels oc_label: name: ip-172-31-5-23.ec2.internal state: add @@ -61,4 +67,26 @@ EXAMPLES = ''' labels: - key: logging-infra-fluentd value: 'true' + +- name: remove a label from a node + oc_label: + name: ip-172-31-5-23.ec2.internal + state: absent + kind: node + labels: + - key: color + value: blue + +- name: Ensure node has these exact labels + oc_label: + name: ip-172-31-5-23.ec2.internal + state: present + kind: node + labels: + - key: color + value: green + - key: type + value: master + - key: environment + value: production ''' -- cgit v1.2.3