Ansible Plugins
Modules (also referred to as “task plugins” or “library plugins”) are discrete units of code that can be used from the command line or in a playbook task. Ansible executes each module, usually on the remote target node, and collects return values.
Lookup
- lookup plugin
- 常用 - 所有
ansible-doc -t lookup -lenvfilepassword- 生成密码到文件consul_kvhashi_vault- vault 中的数据 - 需要 hvacdigdnstxtfileglobfirst_foundconfig- 配置项ansible-config listk8svarsvarnamesdict
ansible -m debug -a "msg={{lookup('env','HOME')}}" localhost
ansible -m debug -a "msg={{lookup('file',lookup('env','HOME')+'/.ssh/id_rsa.pub')}}" localhost
- name: access env
debug: msg={{lookup('env','HOME')}}
- name: access file
debug: msg={{lookup('file',lookup('env','HOME')+'/.ssh/id_rsa.pub')}}