Error
[root@localhost rajesh]# ansible-playbook -i inventory master.yaml -u root -k
SSH password:
ERROR! 'import' is not a valid attribute for a Play
The error appears to be in '/root/rajesh/master.yaml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- import: play1.yaml
^ here
[root@localhost rajesh]# ansible-playbook -i inventory master.yaml -u root -k
SSH password:
ERROR! 'include' is not a valid attribute for a Play
The error appears to be in '/root/rajesh/master.yaml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- include: play1.yaml
^ here
Solution
The include
module has been deprecated with ansible
version 2.16, because
# play1.yaml
---
- name: Install and configure web server
hosts: web
tasks:
- name: Install the latest version of Apache
ansible.builtin.yum:
name: httpd
state: absent
- name: Install the latest version of Apache
ansible.builtin.yum:
name: httpd
state: latest
# play2.yaml
---
- name: Install and configure web server
hosts: web
tasks:
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
- name: Start service httpd, if not started
ansible.builtin.service:
name: httpd
state: started
- name: Start service httpd, if not started
ansible.builtin.service:
name: firewalld
state: stopped
enabled: no
# master.yaml
- import_playbook: play1.yaml
- import_playbook: play2.yaml
Latest posts by rajeshkumar (see all)
- How to get Blackduck Trial version? - December 3, 2023
- PHP ionCube Error: cannot be decoded by this version of the ionCube Loader - December 2, 2023
- Cloudbees CD/RO Error: ectool - November 24, 2023