I just started using Ansible with the GCE module.
I can create a new GCE instance (test-host-01) just fine, but when I add a play
to configure a role (a galaxy role I imported to install oracle java) I get an
error:
GATHERING FACTS ***************************************************************
fatal: [test-host-01] => SSH Error: Permission denied (publickey).
while connecting to 10.240.6.208:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH
debug output to help diagnose the issue.
I am running ansible as user "ansible" and I guess that my SSH public key is
not transferred to the newly created instance, but I have no idea how to do
that from the playbook, and cannot find any documentation on this.
Any suggestions welcome.
Here is my playbook (which is based on the example at
http://docs.ansible.com/ansible/gce_module.html#examples
_________________________________________________________________________________________________
- name: Create new test host
hosts: localhost
connection: local
gather_facts: no
vars:
service_account_email:
141243166259-frlfsl1h4gg713q1chbqe323ld5no...@developer.gserviceaccount.com
pem_file: /home/user/.ssh/ansible-gce.pem
project_id: my-project-id
machine_type: f1-micro
image: ubuntu-1404-trusty-v20150909a
zone: europe-west1-b
diskSizeGb: 40
tasks:
- name: Create disk
gce_pd:
size_gb: 40
name: test-host-01
zone: "{{ zone }}"
image: "{{ image }}"
mode: READ_WRITE
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
- name: Create and launch instance
gce:
instance_names: test-host-01
machine_type: "{{ machine_type }}"
zone: "{{ zone }}"
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
disks: test-host-01
register: gce
- name: Waiting for port 22 to become available
local_action: wait_for host=test-host-01 port=22 delay=10 timeout=60
state=started
with_items: "{{gce.instance_data}}"
sudo: false
- name: Configure instance
hosts: test-host-01
sudo: true
roles:
- ansiblebit.oracle-java
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b2ac6719-e05f-40f9-b517-a3e82b8447aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.