It is possible to set variables for authentication globally for lookup plugins. This way, they do not need to be provided at task level.
export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver"
export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite
export ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER=automation
export ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET=mysecret
export ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS=False
[checkmk_lookup]
server_url = https://myserver
site = mysite
automation_user = automation
automation_secret = mysecret
validate_certs = False
- name: My Task
hosts: localhost
gather_facts: false
vars:
ansible_lookup_checkmk_server_url: "https://myserver"
ansible_lookup_checkmk_site: "mysite"
ansible_lookup_checkmk_automation_user: "automation"
ansible_lookup_checkmk_automation_secret: "mysecret"
ansible_lookup_checkmk_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) }}"
The following task will work, if one of the above methods has been applied.
- 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) }}"