ansible -i hosts all -m setup -vvv
register 配合 debug可以输出某个task 的执行结果
- name: "启动{{item.port}}端口的服务"
shell: ( {{item.start_cmd}} )
async: 10
poll: 0
args:
chdir: /app/{{item.folder}}
warn: no
register: cmd
- debug:
var: cmd
ansible -i hosts -m setup -a "filter=ansible_all_ipv4_addresses"
默认对playbook生效。
在Ad-hoc 命令中前可以添加如下参数使其生效:
ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=actionable ansible -i hosts all -m setup