Ansible Play apt: not happy with installing items: tomcat7 tomcat7-admin on vagrant up | ubuntu 12.0.4 | apt

568 views
Skip to first unread message

Terry Fundak

unread,
Oct 8, 2014, 10:48:47 PM10/8/14
to ansible...@googlegroups.com
Looking for a little advise.... new to ansible ....

Here is the task ....
which is in playbook from
github .... ansible-for-devops.

<extracted> 
tasks:
 
# TOMCAT 7 ###################################################################
 
- name: Install Tomcat 7.
    apt
: "pkg={{ item }} state=installed"
    with_items
:
     
- tomcat7
     
- tomcat7-admin
</extracted> 
______

This apt install fails ( see error below) but is  fine with a login to machine
and
sudo apt-get install 'tomcat7' 'tomcat7-admin'
OR
sudo apt
-get install tomcat7 tomcat7-admin

This playbook is failing and another similar playbook is failing in the same way with the install of java pkgs? and points to not being root..... It says: "are you root?"

Is this a problem of how I am piping ansible to vagrant boxes? or an apt: install problem for java problem? or a ansible syntax problem with unpacking the items? ...
I have not changed this example playbook .... At least I don't think I did ....

Here is the error....

TASK: [Install Tomcat 7.] *****************************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE apt pkg=tomcat7,tomcat7-admin state=installed
<127.0.0.1> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/admin/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile="/Users/admin/.vagrant.d/insecure_private_key"', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295 && echo $HOME/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295'"]
<127.0.0.1> PUT /var/folders/9_/vpy1_2w52xz5tzp1vxs9rs1w0000gp/T/tmpt8VXLU TO /home/vagrant/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295/apt
<127.0.0.1> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/admin/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile="/Users/admin/.vagrant.d/insecure_private_key"', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', u"/bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295/apt; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1412819198.21-6376254845295/ >/dev/null 2>&1'"]
failed: [localhost] => (item=tomcat7,tomcat7-admin) => {"failed": true, "item": "tomcat7,tomcat7-admin"}
stderr: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

msg: 'apt-get install 'tomcat7' 'tomcat7-admin' ' failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?




Michael Peters

unread,
Oct 9, 2014, 3:59:44 PM10/9/14
to ansible...@googlegroups.com
Are you setting sudo to true somewhere else. It's hard to see when
you've just shown a portion of playbook. If not and you just need sudo
for this task, then you can set it per-task like so:

tasks:
# TOMCAT 7 ###################################################################
- name: Install Tomcat 7.
apt: "pkg={{ item }} state=installed"
sudo: true
with_items:
- tomcat7
- tomcat7-admin

> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ee68a8cc-54d1-40d9-abcc-32e9e2ca8b40%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages