当我按如下方式运行这个剧本时,我的剧本出现了问题
可能-攻略-i inventory junos_config_new.yml -check-vvv
name: Juniper SRX configuration compliance checks
hosts: juniper
gather_facts: false
tasks:
set_fact:
config_directory: '{{ "/home/myfolder/ansible_junos/files/" }}'
- name: Syslog server check
junipernetworks.junos.junos_config:
src:'{{ config_directory }}/syslog_config.txt'
src_format: set
comment: Ensure that appropriate Syslog server configured
register: junos_output
diff: true
- debug:
msg: Syslog server check - This check has failed with the following output({{ junos_output.diff.prepared }})
when: junos_output.changed
- debug:
msg: Syslog server check - This check has failed with the following output({{ junos_output.diff.prepared }})
when: junos_output.changed
- name: Admin credentials check
junipernetworks.junos.junos_config:
src: '{{ config_directory }}/admin_user.txt'
comment: Ensure that Admin user have been created
diff: true
register: junos_output1
- debug:
var: junos_output1 ***************************************failed section
- debug:
msg: Admin credentials check - This check has passed with the following output({{ junos_output1.diff.prepared }})
when: not junos_output1.changed
- debug:
msg: Admin credentials check - This check has failed with the following output({{ junos_output1.diff.prepared }})
when: junos_output1.changed
- name: NTP Server check
junipernetworks.junos.junos_config:
src: '{{ config_directory }}/NTP_server.txt'
comment: Ensure that correct NTP servers has been configured
diff: true
- debug:
var: junos_output2
- debug:
msg: NTP Server check - This check has passed with the following output({{ junos_output2.diff.prepared }})
when: not junos_output.changed
- debug:
msg: NTP Server check - This check has failed with the following output({{ junos_output2.diff.prepared }})
when: junos_output.changed
- name: Idle timeout check
junipernetworks.junos.junos_config:
src: '{{ config_directory }}/idle_timeout.txt'
comment: Ensure that idle timeout has been configured
diff: true
- debug:
var: junos_output3
- debug:
msg: Idle timeout check - This check has passed with the following output({{ junos_output3.diff.prepared }})
when: not junos_output.changed
- debug:
msg: Idle timeout check - This check has failed with the following output({{ junos_output3.diff.prepared }})
when: junos_output.changed 该错误似乎位于'/home/gefelas/ansible_junos/junos_config_new.yml':第30行的第5列,但也可能位于文件中的其他位置,具体取决于确切的语法问题。
The offending line appears to be:
register: junos_output1
- debug:
^ here请告诉我我能做些什么..
发布于 2020-06-24 01:35:37
错误的主要原因似乎是您正在为junos_config模块使用diff。根据文档,该模块不支持diff:https://docs.ansible.com/ansible/latest/modules/junos_config_module.html
因此,您需要从junos_config任务中删除该diff: true。
另外,您似乎也有多个缩进问题,例如,这不是正确的缩进:
- name: Admin credentials check
junipernetworks.junos.junos_config:
src: '{{ config_directory }}/admin_user.txt'
comment: Ensure that Admin user have been created
register: junos_output1确保为所有任务正确缩进任务名称和其他任务参数:
- name: Admin credentials check
junipernetworks.junos.junos_config:
src: '{{ config_directory }}/admin_user.txt'
comment: Ensure that Admin user have been created
register: junos_output1因此,我建议检查您的文件并检查所有任务的缩进(请注意,这也可能是由于StackOverflow格式)。
https://stackoverflow.com/questions/62539120
复制相似问题