forked from Checkmk/ansible-collection-checkmk.general
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dedicated README for lookup plugins.
- Loading branch information
1 parent
a01a6d3
commit 5472f93
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Lookup Plugins | ||
|
||
## Using variables for Lookup plugins | ||
It is possible to set variables for authentication globally for lookup plugins. | ||
This way, they do not need to be provided at task level. | ||
|
||
### Method 1: Environment variables | ||
```bash | ||
export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver" | ||
export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite | ||
export ANSIBLE_LOOKUP_AUTOMATION_USER=automation | ||
export ANSIBLE_LOOKUP_AUTOMATION_SECRET=mysecret | ||
export ANSIBLE_LOOKUP_VALIDATE_CERTS=False | ||
``` | ||
|
||
### Method 2: In `ansible.cfg` | ||
```ini | ||
[checkmk_lookup] | ||
server_url = https://myserver | ||
site = mysite | ||
automation_user = automation | ||
automation_secret = mysecret | ||
validate_certs = False | ||
|
||
``` | ||
|
||
### Method 3: In playbooks or the inventory | ||
```yaml | ||
- name: My Task | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
ansible_lookup_checkmk_server_url: "https://myserver" | ||
ansible_lookup_checkmk_site: "mysite" | ||
ansible_lookup_automation_user: "automation" | ||
ansible_lookup_automation_secret: "mysecret" | ||
ansible_lookup_validate_certs: false | ||
|
||
tasks: | ||
- name: Get the attributes of myhost | ||
ansible.builtin.debug: | ||
msg: "Attributes of myhost: {{ attributes }}" | ||
vars: | ||
attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" | ||
``` | ||
### Example | ||
The following task will work, if one of the above methods has been applied. | ||
```yaml | ||
- name: My Task | ||
tasks: | ||
- name: Get the attributes of myhost | ||
ansible.builtin.debug: | ||
msg: "Attributes of myhost: {{ attributes }}" | ||
vars: | ||
attributes: "{{ lookup('checkmk.general.host', 'myhost', effective_attributes=True) }}" | ||
``` |