Skip to content

Commit

Permalink
Ansible Cheat sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
vilsijain authored Feb 9, 2021
1 parent ecf9e10 commit 60ecfce
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Ansible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
**The Ansible k8s module enables you to manage Kubernetes objects with Ansible playbooks.**
he k8s_auth module helps manage authentication
.
πŸ–K8s_auth parameters


Use the k8s_auth module with clusters requiring explicit authentication procedures (you log
in for a token, interact with the API using the token, then log out to revoke).

-api_key Token used to authenticate with an API. When state is set to absent, this specifies the token to revoke.

-password Password for authenticating with an API.

-username Username for authenticating with an API.

-validate_certs Yes β†’ Verify the API server's SSL certificates.

-host The API server. Required.

-State Present β†’ Connect to the API server using the URL specified
in host and log in.
-Absent β†’ Revoke the auth token specified in api_key.


πŸ–K8s_auth example
- name: Obtain access token
k8s_auth:
username: admin
password: "{{ k8s_admin_password }}"
register: k8s_auth_results
- name: Create a namespace with token
k8s:
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
name: examplespace
kind: Namespace
state: present


πŸ–K8s parameters
An API set up with HTTP Basic Auth can require an access key. For alternate access
methods, such as OAuth2 in OpenShift, use the k8s_auth module.

-api_key Token to authenticate with an API. Env variable: K8S_AUTH_API_KEY

-password Password for an API. Env variable: K8S_AUTH_PASSWORD

-username Username for an API. Env variable: K8S_AUTH_USERNAME

Other parameters allow you to perform most actions you could
otherwise perform manually with kubectl

-host URL of the API. Env variable: K8S_AUTH_HOST

-src Path to a file containing a valid YAML definition of an object or objects to
be created or updated.

-kubeconfig Path to an existing Kubernetes config file.

-name Specifies an object name when creating, deleting, or discovering an
object. Use in conjunction with api_version, kind, or namespace to
identify a specific object.

-namespace Specifies the namespace to use.

-kind Specifies an object model.

-state Present β†’ Create the object.
Absent β†’ Delete an existing object.

0 comments on commit 60ecfce

Please sign in to comment.