Here’s a snippet of a task I’m trying to run:
TODO: ignore_errors because we don’t know why this even executes when ${shell_accounts} is not set
- authorized_key: user=${item} key=‘$FILE(${playbook_files_private}/keys/${item}_id_rsa.pub)’
with_items: ${shell_accounts}
when_set: ${shell_accounts}
ignore_errors: yes
tags: - keys.user
First off I tried to use when_set to test if the variable is there. That conditional should be false and ignore the task, but it doesn’t. Then I even went to put a hack to ignore errors and move on but my playbook gets aborted still. I’m using the latest pull as of a few minutes of this post.
Result of $ ansible-playbook -i “lamp5.cf5.kernelfire.com,” /etc/ansible/strategybooks/base.yml --extra-vars “hosts=lamp5.cf5.kernelfire.com”:
PLAY [Base Playbook] *********************
GATHERING FACTS *********************
ok: [lamp5.cf5.kernelfire.com]
PLAY [Proxy Playbook] *********************
TASK: [user name=root password=$root_passwd state=present] *********************
skipping: [lamp5.cf5.kernelfire.com]
TASK: [template src= dest=/root/.bashrc owner=root group=root mode=0644] *********************
changed: [lamp5.cf5.kernelfire.com]
TASK: [template src= dest=/root/.bash_profile owner=root group=root mode=0644] *********************
changed: [lamp5.cf5.kernelfire.com]
TASK: [template src= dest=/root/.bash_logout owner=root group=root mode=0644] *********************
changed: [lamp5.cf5.kernelfire.com]
PLAY [Proxy Playbook] *********************
TASK: [template dest=/etc/motd] *********************
changed: [lamp5.cf5.kernelfire.com]
PLAY [Proxy Playbook] *********************
TASK: [template dest=/root/.ssh/authorized_keys] *********************
changed: [lamp5.cf5.kernelfire.com]
TASK: [file dest=/home/ state=directory owner= group=users mode=0700] *********************
skipping: [lamp5.cf5.kernelfire.com] => (item=${shell_accounts})
TASK: [authorized_key user= key=‘$FILE(${playbook_files_private}/keys/${item}_id_rsa.pub)’] *********************
fatal: [lamp5.cf5.kernelfire.com] => /etc/ansible/strategybooks/files_private/keys/${shell_accounts}_id_rsa.pub does not exist
FATAL: all hosts have already failed – aborting
PLAY RECAP *********************
lamp5.cf5.kernelfire.com : ok=7 changed=5 unreachable=1 failed=0
Looks like I’m doing something wrong?