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?