##### SUMMARY
When I want to use skip the task if the extra-vars parameter is passed like default in playbook from the role
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME
ansible-core
##### ANSIBLE VERSION
ansible 2.6.1
config file = /etc/ansible/playbooks/example/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
##### CONFIGURATION
ansible 2.6.1
config file = /etc/ansible/playbooks/example/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
##### OS / ENVIRONMENT
CentOS Linux release 7.5.1804 (Core)
##### STEPS TO REPRODUCE
roles/common/tasks/main.yml
---
- name: Reloading Service on {{ansible_hostname}}
service:
name: "{{ item }}"
state: reloaded
with_items: "{{ (servicename is defined) | ternary((servicename|default('')).split(','),[]) }}"
- name: checking the service status {{ansible_hostname}}
service:
name: "{{ item }}"
state: started
with_items: "{{ (servicename is defined) | ternary((servicename|default('')).split(','),[]) }}"
playbook.yaml
- name: checking service is skipped by default
hosts: {{host}}
vars_files:
- /etc/ansible/inventories/group_vars/common.yaml
serial: 1
roles:
- common
####ansible command
ansible-playbook -vv --vault-id sre@/opt/sre -i /etc/ansible/inventories/funccphosts test.yml --extra-vars "host=node1,node2 servicename="
##### EXPECTED RESULTS
I want to just skip the task of service if I am not passing any service name variable
##### ACTUAL RESULTS
TASK [common_role_ : Reloading Service on node1] ****************************
task path: /etc/ansible/roles/common_role_cow/tasks/main.yml:17
Thursday 27 September 2018 13:06:27 +0000 (0:00:00.529) 0:00:09.391 ****
fatal: [node1]: FAILED! =>
msg: '''list object'' has no attribute ''split'''