How to sync over directories that exist locally?

I am trying to do something like this:

  • name: setup user home directories
    synchronize: src=homes/{{item.username}} dest=/home/{{item.username}}
    owner={{item.username}}
    group={{item.username}}
    with_items: ssh_users
    ignore_errors: yes

So basically, I want it to copy a home directory for users that have one. Not everyone will have one because not everyone really needs, say, their own customized .vimrc, etc. In those cases, I’d like Ansible to just skip it. But I don’t know how to do that. Running the above gives me:

TASK: […/users | setup user home directories] ********************************
fatal: [default] => input file not found at //roles/users/files/homes/ or /roles/users/homes/

FATAL: all hosts have already failed – aborting

This looks a bit like this bug, https://github.com/ansible/ansible/issues/7354 but they aren’t doing exactly the same thing I was trying to do.

This was all in 1.7.1.

Any ideas or suggestions?

Thanks!

Tim

Hi Tim,

We were unable to reproduce the above situation, and this message is different, it’s basically saying that the input is missing. So to me this seems like a new, but unreported issue.

ignore_errors basically only deals with the return of the module, so what I think we need to do here is explicitly check ignore_errors in the action plugin when the files are missing, so that this can work. Long story short is action_plugins are fiddly beasts that don’t always have all the native behavior for things like ‘ignore_errors’ and we occasionally have to make those work with some extra code.

If you would like to open a new ticket in GitHub we can take care of this.

The temporary workaround might be to put a “.dir” file or something in each directory, so it can find something to transfer, though I agree that’s not obvious or optimal long term.

–Michael