I have a task like this:
- name: cloning source from git
command: git clone -b {{item.version}} git@url/{{item.name}}.git /opt/src/{{item.name}}
with_items: - { name: ‘pkg1’, version: ‘allow_overriding_pin’ }
- { name: ‘pkg2’, version: ‘allow_overriding_pin’ }
- { name: ‘pkg3’, version: ‘master’ }
- { name: ‘pkg4’, version: ‘master’ }
- { name: ‘pkg5’, version: ‘master’ }
- { name: ‘pkg6’, version: ‘master’ }
notify: - Restart nginx
And its currently locking up when executing, I ran playbook with -vvv to get a little better output and came up with:
TASK: [cloning source from git] ***********************************************
<192.168.21.254> ESTABLISH CONNECTION FOR USER: vagrant
<192.168.21.254> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=vagrant’, ‘-o’, ‘ConnectTimeout=10’, ‘192.168.21.254’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1374382621.36-34466305103908 && chmod a+rx $HOME/.ansible/tmp/ansible-1374382621.36-34466305103908 && echo $HOME/.ansible/tmp/ansible-1374382621.36-34466305103908’”]
<192.168.21.254> REMOTE_MODULE command git clone -b allow_overriding_pin git@/.git /opt/src/
<192.168.21.254> PUT /tmp/tmpS5fOOr TO /home/vagrant/.ansible/tmp/ansible-1374382621.36-34466305103908/command
<192.168.21.254> EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=vagrant’, ‘-o’, ‘ConnectTimeout=10’, ‘192.168.21.254’, “/bin/sh -c ‘/usr/bin/python /home/vagrant/.ansible/tmp/ansible-1374382621.36-34466305103908/command; rm -rf /home/vagrant/.ansible/tmp/ansible-1374382621.36-34466305103908/ >/dev/null 2>&1’”]
Which isn’t enough to figure out exactly why its locking up. I think maybe its because the SSH key requires a password but I’m trying to figure out how I could get more detailed output to findout exactly what the problem is. Is there a flag I can pass to ansible that will output the last executed line so that I could set a PDB and inspect things from there?
Outside of that my questions are:
- If it is the SSH key password, is there a way to get ansible to prompt me for the pw?
- Is that the best way to structure a task that is cloning from git?
- Can I factor out my with items into a variable inside a role? I re-use that same list of services in 3 tasks but since its specific to the role, I don’t want to create a group_var/host_var.