error using copy module in conjunction with become and with_items

39 views
Skip to first unread message

R.B. Boyer

unread,
Jan 18, 2016, 8:26:20 AM1/18/16
to Ansible Project
This is the error:

fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! privilege output closed while waiting for password prompt:\nBECOME-SUCCESS-adezzvrxzmmrvcjmhockfqrcaofjafii\nd463cad77a9f7ca30d2eee449d151ffec7209a6b\n"}



Relevant file snippets to reproduce:
# ansible.cfg
[defaults]
hostfile      
= ./hosts
retry_files_enabled
= False

#./hosts
[local]
localhost    ansible_connection
=local

#test-priv-fails.yml
---
- hosts: local
  become
: true
  tasks
:
   
## if doing them both in the same task, this does not work
   
- copy:
        src
: '{{ item }}'
        dest
: '/usr/lib/jvm/java-7-oracle/jre/lib/security/{{ item }}'
      with_items
:
       
- local_policy.jar
       
- US_export_policy.jar

#test-priv-works.yml
---
- hosts: local
  become
: true
  tasks
:
   
## if doing them one at a time, this works
   
- copy:
        src
: '{{ item }}'
        dest
: '/usr/lib/jvm/java-7-oracle/jre/lib/security/{{ item }}'
      with_items
:
       
- local_policy.jar
   
- copy:
        src
: '{{ item }}'
        dest
: '/usr/lib/jvm/java-7-oracle/jre/lib/security/{{ item }}'
      with_items
:
       
- US_export_policy.jar

#test-nonpriv-works.yml
---
- hosts: local
  become
: false
  tasks
:
   
## if doing them both in the same task without BECOME, this works
   
- copy:
        src
: '{{ item }}'
        dest
: '/home/someuser/tmp/{{ item }}'
      with_items
:
       
- local_policy.jar
       
- US_export_policy.jar

The actual command and full failure in the failure mode is:

$ ansible-playbook -l local --ask-become-pass -vvvv foobar.yml 

TASK [java : release the JCE policy restrictions] ******************************
task path
: foobar.yml:22
ESTABLISH LOCAL CONNECTION FOR USER
: someuser
localhost EXEC
/bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=weorgfizbirfewrvzcpwtnjxiuiktohq] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-weorgfizbirfewrvzcpwtnjxiuiktohq; rc=flag; [ -r /usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar ] || rc=2; [ -f /usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar ] || rc=1; [ -d /usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar ] && rc=3; python -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc}  "/usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar && exit 0; (python -c '"'"'"'"'"'"'"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1();
afile = open("'"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
 hasher.update(buf)
 buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (python -c '"'"'"'"'"'"'"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha();
afile = open("'"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
 hasher.update(buf)
 buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (echo '"'"'"'"'"'"'"'"'0  '"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/local_policy.jar)'"'"''

localhost EXEC
( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1453053635.85-233846757354791 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1453053635.85-233846757354791 )" )
localhost PUT
/tmp/tmpcvo1Yk TO /home/someuser/.ansible/tmp/ansible-tmp-1453053635.85-233846757354791/file
localhost EXEC
/bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=liutrhwayfctwttmlspuuylxzbqyplzq] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-liutrhwayfctwttmlspuuylxzbqyplzq; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/someuser/.ansible/tmp/ansible-tmp-1453053635.85-233846757354791/file; rm -rf "/home/someuser/.ansible/tmp/ansible-tmp-1453053635.85-233846757354791/" > /dev/null 2>&1'"'"''
localhost EXEC
/bin/sh -c 'sudo -H -S  -p "[sudo via ansible, key=crizpgzqqcagtlqqfzuqygnsypxhvoyt] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-crizpgzqqcagtlqqfzuqygnsypxhvoyt; rc=flag; [ -r /usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar ] || rc=2; [ -f /usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar ] || rc=1; [ -d /usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar ] && rc=3; python -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc}  "/usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar && exit 0; (python -c '"'"'"'"'"'"'"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1();
afile = open("'"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
 hasher.update(buf)
 buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (python -c '"'"'"'"'"'"'"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha();
afile = open("'"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
 hasher.update(buf)
 buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2>/dev/null) || (echo '"'"'"'"'"'"'"'"'0  '"'"'"'"'"'"'"'"'/usr/lib/jvm/java-7-oracle/jre/lib/security/US_export_policy.jar)'"'"''

fatal
: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! privilege output closed while waiting for password prompt:\nBECOME-SUCCESS-crizpgzqqcagtlqqfzuqygnsypxhvoyt\nd463cad77a9f7ca30d2eee449d151ffec7209a6b\n"}


Reply all
Reply to author
Forward
0 new messages