执行此操作时,我正在碰到此消息:
ansible-playbook -i inventory junos_config_new.yml --check -vvv
ansible-playbook 2.9.9配置文件= /etc/ansible/ansible.cfg 配置的模块搜索路径= ['/root/.ansible/plugins/modules', '/ usr / share / ansible / plugins / modules'] ansible python module location = /root/.local/lib/python3.6/site-packages/ansible可执行位置= / usr / bin / ansible-playbook python版本= 3.6.8(默认值,11月21日 2019,19:31:34)[GCC 8.3.1 20190507(Red Hat 8.3.1-4)]使用 /etc/ansible/ansible.cfg,因为配置文件host_list拒绝解析 / home / gefela / ansible_junos / inventory,因为它没有通过 verify_file()方法脚本拒绝分析 / home / gefela / ansible_junos / inventory,因为它没有通过 verify_file()方法自动拒绝解析 / home / gefela / ansible_junos / inventory,因为它没有通过 verify_file()方法已解析/ home / gefela / ansible_junos / inventory 带有ini插件的广告资源
PLAYBOOK:junos_config_new.yml ********************************************** ****************************************************** ************************************** 1在junos_config_new.yml中播放
这是我拥有的剧本...
name: Juniper SRX configuration compliance checks
hosts: juniper
gather_facts: false
connection: local
tasks:
- name: Syslog server checks
junos_config:
src: ~/ansible_junos/files/syslog_config.txt
comment: Ensure that appropriate Syslog server configured
register: junos_output
- debug:
var: junos_output
- name: success
debug:
msg: Syslog server check - This check has passed with the following output({{ junos_output }})
when: not junos_output.changed
- name: failed
debug:
msg: Syslog server check - This check has failed with the following output({{ junos_output }})
when: junos_output.changed
- name: Admin credentials check
junos_config:
src: ~/ansible_junos/files/admin_user.txt
comment: Ensure that Admin user havee been created
register: junos_output
- debug:
var: junos_output
- name: success
debug:
msg: Admin credentials check - This check has passed with the following output({{ junos_output }})
when: not junos_output.changed
- name: failed
debug:
msg: Admin credentials check - This check has failed with the following output({{ junos_output }})
when: junos_output.changed
目录〜/ ansible_junos / files / syslog_config.txt在正确的位置 〜/ ansible_junos / files /应该是放置所有要与防火墙进行比较的配置的正确位置吗?
请让我知道..
答案 0 :(得分:1)
这是因为~
是一项bash功能,而不是实际的路径组件;您的 shell 展开~
表示当前用户(或直接用~
命名的用户)的主目录,但是,ansible模块必须退出他们使用expanduser
的行为方式。
您可以尝试通过| expanduser
filter发送文件名,或者可能必须使用gather_facts: true
才能访问ansible_env.HOME
- set_fact:
config_directory: '{{ "~/ansible_junos/files" | expanduser }}'
- name: Syslog server checks
junos_config:
src: '{{ config_directory }}/syslog_config.txt'
comment: Ensure that appropriate Syslog server configured
register: junos_output
答案 1 :(得分:0)
src jues需要“ admin_user.txt”
- name: Admin credentials check
junos_config:
src: "admin_user.txt"
comment: Ensure that Admin user havee been created
register: junos_output
添加,您可以在files / admin_user.txt中添加admin_user.txt
答案 2 :(得分:0)
我不得不更改清单文件(ansible_user和ansible_password)并进行更改
到