First of all i want to tell you how amazed i am with Ansible! The more i learn it the more amazed i am, it is a great peace of software.
But now, as always, i have a problem
I’ve been having problems with rsync and ansible for a few days now, so i guess i am missing something obvious
I want to rsync files from the host machine (ansible “master”) to some other machine but also overwrite some of the files on target machine that require sudo to access. Lets call my user test, this user exists on both “master” and target machine and is part of sudo group on both machines.
My play includes:
remote_user: nettv
sudo: True
.
.
.
- name: RSYNC all the needed files for streamer
#synchronize: src=/home/test/streamer-image/opt/ dest=/opt/ rsync_timeout=5 rsync_path=“sudo rsync”
#command: sudo rsync -avP -e “ssh -o StrictHostChecking=no” --partial test@ansible-master.acme.com /streamer-image/opt/ /opt/
local_action: shell rsync -avP “ssh -p {{ansible_ssh_port}}” --partial --rsync-path=“sudo rsync” /home/test/streamer-image/opt/ test@{{inventory_hostname}}:/opt/
when: roles_var == “str”
When i try to use synchronize without sudo rsync i get permission denied which i think is normal.
When i try to use synchronize with sudo rsync i get that tty is not present. I have read about !requiretty but i would like to avoid this approach.
When i try to use command with sudo it just hangs (i guess it is waiting for sudo password but without a prompt)
When i try to use local_action with sudo i get that tty is not present.
In ansible.cfg I have this:
sudo_user = root #But i have tried with test also, but if i change to test my tasks won’t run because of premissions (this puzzles me)
executable = /bin/sh #But i have tired with /bin/bash also.
Files that are needed for example grub i will copy separately and describe handlers and such, but the rest of the files i need to copy “in bulk” and overwrite some of the files in /opt/, /etc/ and such.
So, what am i doing wrong? Am i missing something obvious? Is there some workaround?
If you need any verbose output for any of the cases i will be happy to provide them
Any idea is highly appreciated! Thank you in advance!