Skip to content

Instantly share code, notes, and snippets.

@omersiar
Created February 10, 2020 06:35
Show Gist options
  • Save omersiar/b9ea633049cf75ea7548ecf3ffc8f0f4 to your computer and use it in GitHub Desktop.
Save omersiar/b9ea633049cf75ea7548ecf3ffc8f0f4 to your computer and use it in GitHub Desktop.
- hosts: localhost
module_defaults:
group/k8s:
host: "https://api.ocppreprod.aefesopenshift.com:6443"
validate_certs: false
vars:
user_login: *****
user_pass: ****
tasks:
- block:
- name: Log in (obtain access token)
k8s_auth:
username: "{{ user_login }}"
password: "{{ user_pass }}"
register: k8s_auth_results
- name: Get a list of all configmap
k8s_info:
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
api_version: v1
kind: ConfigMap
namespace: ess-test
register: config_list
always:
- name: If login succeeded, try to log out (revoke access token)
when: k8s_auth_results.k8s_auth.api_key is defined
k8s_auth:
state: absent
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment