I think I'm missing something fundamental.
I have a Playbook for doing Google Computer Engine (gce) stuff and it's
based on playbooks I found on the Internet. The tasks are defined within
the playbook.
- name: google compute engine testing
hosts: localhost
connection: localhost
gather_facts: no
vars:
project_id: AAAA
instance_names: BBBB
service_account_email: [email protected]
credentials_file: CCCCC
image: ubuntu-1604-xenial-v20160721
machine_type: f1-micro
zone: us-central1-b
tasks:
- name: create instance
gce:
instance_names: "{{ instance_names }}"
zone: "{{ zone }}"
machine_type: "{{ machine_type }}"
image: "{{ image }}"
project_id: "{{ project_id }}"
credentials_file: "{{ credentials_file }}"
service_account_email: "{{ service_account_email }}"
register: gce
tags: google
- name: wait for ssh
wait_for:
host: "{{ item.public_ip }}"
port: 22
delay: 10
timeout: 60
state: started
with_items: "{{ gce.instance_data }}"
tags: google
How would I change this into a Role called gce-instance?
I assume the vars: and tasks would just move to the Role's tasks/main.yml)?
But how do I get the below stuff into the Role?
- name: google compute engine testing
hosts: localhost
connection: localhost
gather_facts: no
Sample Playbook
- hosts: all
vars:
pre_tasks:
roles:
- { role: gce-instance }
I do not understand what
- name: google compute engine testing
hosts: localhost
connection: localhost
gather_facts: no
does. Is it setting up defaults for the below tasks?
tasks:
# gcloud compute machine-types list
# gcloud compute images list
#
- name: create instance
gce:
instance_names: "{{ instance_names }}"
zone: "{{ zone }}"
machine_type: "{{ machine_type }}"
image: "{{ image }}"
project_id: "{{ project_id }}"
credentials_file: "{{ credentials_file }}"
service_account_email: "{{ service_account_email }}"
register: gce
tags: google
--
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/f8735885-4a49-4dd2-9ee6-9540dd8abc80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.