【发布时间】:2017-11-09 23:24:49
【问题描述】:
从Unable to open shell: Ansible v2.3.1.0升级
我遇到了,
[弃用警告]:保留包含是为了向后兼容,但不鼓励使用。模块文档 详细信息页面可能会解释有关此基本原理的更多信息。此功能将在以后的版本中删除。弃用 可以通过在 ansible.cfg 中设置 deprecation_warnings=False 来禁用警告。
来自
---
- hosts: ios
gather_facts: no
connection: local
tasks:
- name: obtain login credentials
include_vars: secrets.yml
- name: define provider
set_fact:
provider:
host: "{{ inventory_hostname }}"
username: "{{ creds['username'] }}"
password: "{{ creds['password'] }}"
#Uncomment next line if enable password is needed
#auth_pass: "{{ creds['auth_pass'] }}"
transport: cli
- include: tasks/ios_command-freeform.yml
使用include_vars 涉及文件夹内容的正确方法是什么? (尝试改用它,但 "tasks" 中的 yml-s 最终被主要游戏忽略)。
提前致谢
[root@ymlhost-3 ansible-yml]# cat cisco-play.yml
---
- name: cisco-yml
hosts: cisco
gather_facts: no
connection: local
tasks:
- name: obtain login credentials
include_vars: secrets.yml
- name: define provider
set_fact:
provider:
host: "{{ inventory_hostname }}"
username: "{{ creds['username'] }}"
password: "{{ creds['password'] }}"
auth_pass: "{{ creds['auth_pass'] }}"
authorize: yes
- name: Include all .yml
include_vars:
dir: 'tasks'
extensions:
- json
- yml
[root@ymlhost-3 ansible-yml]#
也尝试了不同的形式
[root@ymlhost-3 ansible-yml]# cat cisco-play.yml
---
- name: cisco-yml
hosts: cisco
gather_facts: no
connection: local
tasks:
- name: obtain login credentials
include_vars: secrets.yml
- name: define provider
set_fact:
provider:
host: "{{ inventory_hostname }}"
username: "{{ creds['username'] }}"
password: "{{ creds['password'] }}"
auth_pass: "{{ creds['auth_pass'] }}"
authorize: yes
- name: Include all .yml files except bastion.yml (2.3)
include_vars:
dir: 'vars'
ignore_files: 'bastion.yml'
extensions: ['yml']
[root@ymlhost-3 ansible-yml]#
【问题讨论】:
-
有什么问题,有什么问题,
include的代码在哪里?包含变量与它无关,您正在对代码的错误部分进行故障排除。 -
已更新。如果我切换回旧的包含语句,它可以工作。但较新的没有
-
大约 90% 的问题与问题无关。剩下的部分可以通过花一分钟时间思考警告的含义来解决,而不是在黑暗中开枪。