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: me@AAAA.iam.gserviceaccount.com
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: