4. debug 调试模块,用于在调试中输出信息 常用参数: msg:调试输出的消息 var:将某个任务执行的输出作为变量传递给debug模块,debug会直接将其打印输出 verbosity:debug的级别(默认是0级,全部显示) fail 用于终止当前playbook的执行,通常与条件语句组合使用,当满足条件时,终止当前play的运行。可以直接由failed_when取代。
# script模块 # 作用:在远程主机运行本地的脚本; # 调用格式: # -m script -a "/PATH/TO/SCRIPT_FILE"; # 参数: # creates:如果其后跟的文件存在,则不执行脚本; # removes:如果其后跟的文件存在,则执行脚本; [root@ansible1 opt]# cat /opt/test.sh #!/bin/bash echo "hello word" # 在本地运...
msg:调试输出的消息 var:将某个任务执行的输出作为变量传递给debug模块,debug会直接将其打印输出 verbosity:debug的级别(默认是0级,全部显示) debug模块示例: --- - hosts:192.168.21.128gather_facts: False tasks:-name: command run line shell: date register: result-name: show debug info debug:var=result...
register:print_result#将之前命令的输出结果保存在变量print_result里 -debug:var=print_result#将变量的值作为debug输出出来。 [root@ansible scripts]#ansible-playbook test_register.yaml PLAY[all]*** TASK[GatheringFacts]***
- hosts: proxyservers tasks: - name: "get host port info" shell: netstat -lntp register: host_port - name: "print host port" debug: #msg: "{{ host_port }}" # 输出全部信息 #msg: "{{ host_port.cmd }}" # 引用方式一 msg: "{{ host_port['stdout_lines'] }}" # 引用方式二 ...
只能指定变量,不能指定自定义信息,且变量不能加{{}}包围,而是直接的变量名。verbosity:#Anumber that controls when the debug is run,ifyousetto3it will only run debug when-vvv or above # 控制debug运行的调试级别,有效值为一个数值N。 script 模块...
name: Run installation script command: /destination/path/extracted_package/install.sh args: chdir: /destination/path/extracted_package register: installation_output ignore_errors: true name: Check installation output debug: var: installation_output.stderr_lines ...
Debug output can also include secret information despite no_log settings being enabled, which means debug mode should not be used in production. Type: boolean Default: False Ini: Section: [defaults] Key: debug Environment: Variable: ANSIBLE_DEBUG DEFAULT_EXECUTABLE Description: This ...
2 script 模块 3 copy 模块 常用参数: 4 yum_repository模块 5 yum 模块 常用参数: 6 systemd 模块 常用参数: 7 group 模块 常用参数: 8 user 模块 常用参数: 9 file 模块 常用参数: 10 cron 模块 常用参数: 11 debug模块 常用参数: 12 template 模块 13 lineinfile 模块 常用参数 14 blockinfile 模块...
#libvirt_lxc_noseclabel = yes [colors] #highlight = white #verbose = blue #warn = bright purple #error = red #debug = dark gray #deprecate = purple #skip = cyan #unreachable = red #ok = green #changed = yellow #diff_add = green #diff_remove = red #diff_lines = cyan [diff]...