~/.bashrc will not be sourced from cron task. .bashrc is sourced only
when bash is started as interactive shell (see man bash), but cron
tasks are started with sh -c (not bash nor interactive).

You can source your .bashrc manually or you can setup your
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY:

*/5 * * * * ...; AWS_ACCESS_KEY_ID=id AWS_SECRET_ACCESS_KEY=secret
ansible-pull ...

or:

*/5 * * * * ...; source /path/to/your/.bashrc; ansible-pull ...

2013/11/29 Nicolas G <[email protected]>:
> Hi All,
>
> This is a simple playbook I have to test the S3 module which is working fine
> but I'm having problems when I run the same in pull mode from cron:
>
> # s3example.yml
> ---
> - hosts: localhost
>   connection: local
>   user: root
>   tasks:
>     - name: download file from s3
>       s3: bucket=my-bucket object=packages/my-package.tar.gz
> dest=/my-package.tar.gz mode=get
>
>
>
> # Ansible push works OK , the files get's downloaded from S3
> ansible-playbook zabbix-agent.yml
>
>
> # manually running the same playbook in pull mode also works OK
> ansible-pull -U [email protected]:my-company/myRepo.git -d /tmp/testing -o
> --checkout=test s3example.yml
>
>
> # The problem is when using ansible-pull from cron
> # /etc/cron.d/ansible-pull :
> */5 * * * * root source /opt/ansible/hacking/env-setup  >& /dev/null;
> ansible-pull -U [email protected]:my-company/myRepo.git -d /tmp/testing -o
> --checkout=test s3example.yml >>/var/log/test-ansible-pull.log 2>&1
>
>
> # this is what I see in /var/log/test-ansible-pull.log
> TASK: [ download file from s3] **************************************
> failed: [localhost] => {"failed": true}
> msg: No handler was ready to authenticate. 1 handlers were checked.
> ['HmacAuthV1Handler'] Check your credentials
>
> FATAL: all hosts have already failed -- aborting
>
> This is happening in ansible 1.5 (devel 44ca015d87) last updated 2013/11/29
> 11:20:12 (GMT +000) .
>
> I have  AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY defined in my ~/.bashrc
> .
>
> Any clue ?
>
> Thanks in advance,
> Nicolas.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Krzysztof Warzecha

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to