Reputation:
upgrading from Unable to open shell: Ansible v2.3.1.0
I run into,
[DEPRECATION WARNING]: include is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
---
- 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
what is the proper way of using include_vars
to involve a folder content? (Trying to use this instead but yml-s inside "tasks
" end up getting ignored by the main play).
[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]#
Upvotes: 0
Views: 1666
Reputation: 68559
Ansible is telling you the include
directive has been deprecated and will not work in future versions, reference:
include - include a play or task list.
DEPRECATED
The include action was too confusing, dealing with both plays and tasks, being both dynamic and static. This module will be removed in version 2.8. As alternatives use include_tasks, import_playbook, import_tasks.
Replace:
- include: tasks/ios_command-freeform.yml
With:
- import_tasks: tasks/ios_command-freeform.yml
Or:
- include_tasks: tasks/ios_command-freeform.yml
Difference is explained here: Differences Between Static and Dynamic. There is likely no difference in your use case, so go with import_tasks
.
Upvotes: 1