我想連接到EC2實例,並在劇本運行任務運行在EC2上instanse ansible任務
playbook.yml:
---
- hosts: 'all'
remote_user: 'ubuntu'
vars:
ruby_version: '2.2.4'
user: 'deploy'
home: '/home/{{ user }}'
rbenv_root: '{{ home }}/.rbenv'
name: 'app'
application: '{{ home }}/applications/{{ name }}'
tasks:
- name: 'apt | install dependencies'
action: 'apt pkg={{ item }}'
with_items:
- 'build-essential'
- 'libssl-dev'
- 'libyaml-dev'
- 'libreadline6-dev'
- 'zlib1g-dev'
- 'libcurl4-openssl-dev'
- 'git'
- 'nginx'
- 'postgresql'
- 'postgresql-contrib'
- 'libpq-dev'
- 'imagemagick'
- 'libmagickwand-dev'
- 'htop'
運行命令:
ansible-playbook -i11.111.1.111, playbook.yml
,並得到這個:
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [11.111.1.111]
TASK: [apt | install dependencies] ********************************************
failed: [11.111.1.111] => (item=build-essential,libssl-dev,libyaml-dev,libreadline6-dev,zlib1g-dev,libcurl4-openssl-dev,git,nginx,postgresql,postgresql-contrib,libpq-dev,imagemagick,libmagickwand-dev,htop) => {"failed": true, "item": "build-essential,libssl-dev,libyaml-dev,libreadline6-dev,zlib1g-dev,libcurl4-openssl-dev,git,nginx,postgresql,postgresql-contrib,libpq-dev,imagemagick,libmagickwand-dev,htop"}
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?
我想我編輯指定AWS_ACCESS_KEY和AWS_SECRET_KEY,但我找不到怎麼辦呢