mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-08 14:02:38 +00:00
handle aliases for lookup and inventory plugins for authentication options (#500)
Honor aliases for lookup and inventory plugins rebase and extend the following PR #71 ISSUE TYPE Bugfix Pull Request Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
46
tests/integration/targets/setup_kubeconfig/tasks/main.yml
Normal file
46
tests/integration/targets/setup_kubeconfig/tasks/main.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
- fail:
|
||||
msg: "kubeconfig_operation must be one of 'revert' or 'save'"
|
||||
when: kubeconfig_operation not in ["revert", "save"]
|
||||
|
||||
- set_fact:
|
||||
src_kubeconfig: "{{ (kubeconfig_operation == 'save') | ternary(kubeconfig_default_path, kubeconfig_custom_path) }}"
|
||||
dest_kubeconfig: "{{ (kubeconfig_operation == 'save') | ternary(kubeconfig_custom_path, kubeconfig_default_path) }}"
|
||||
|
||||
- name: check if source kubeconfig exists
|
||||
stat:
|
||||
path: "{{ src_kubeconfig }}"
|
||||
register: _src
|
||||
|
||||
- name: check if destination kubeconfig exists
|
||||
stat:
|
||||
path: "{{ dest_kubeconfig }}"
|
||||
register: _dest
|
||||
|
||||
- fail:
|
||||
msg: "Both {{ src_kubeconfig }} and {{ dest_kubeconfig }} do not exist."
|
||||
when:
|
||||
- not _src.stat.exists
|
||||
- not _dest.stat.exists
|
||||
|
||||
- name: Generate user cert_file, key_file, and hostname
|
||||
block:
|
||||
- name: Generate user credentials files
|
||||
test_inventory_read_credentials:
|
||||
kube_config: "{{ (_src.stat.exists) | ternary(src_kubeconfig, dest_kubeconfig) }}"
|
||||
dest_dir: "{{ user_credentials_dir }}"
|
||||
when: user_credentials_dir is defined
|
||||
|
||||
- block:
|
||||
- name: "Copy {{ src_kubeconfig }} into {{ dest_kubeconfig }}"
|
||||
copy:
|
||||
remote_src: true
|
||||
src: "{{ src_kubeconfig }}"
|
||||
dest: "{{ dest_kubeconfig }}"
|
||||
|
||||
- name: "Delete {{ src_kubeconfig }}"
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ src_kubeconfig }}"
|
||||
|
||||
when: _src.stat.exists
|
||||
Reference in New Issue
Block a user