Hi,
I was trying to write simple task in ansible to create HDFS user hone directory if it’s not exist. So following is the task I wrote
- name: create user home dir in HDFS
shell: shell: “hadoop fs -test -d /user/{{ item.name }} || (hadoop fs -mkdir /user/{{ item.name }} && hadoop fs -chown {{ item.name }} /user/{{ item.name }})”
when: “‘hdfsuser’ in {{ item.groups }} and ‘{{ inventory_hostname }}’ in [‘hadoop-client01.dev.abc.com’]”
with_items: ssh_users
remote_user: hdfs
tags:
- hadoop
But I want to make it more simplified by breaking the shell command into two.
so is it possible to have conditional dependent two commands in one single task.
or is there better way to do this ?
Thanks