Skip to Content
Practical Ansible 2
book

Practical Ansible 2

by Daniel Oh, James Freeman, Fabio Alessandro Locati
June 2020
Intermediate to advanced content levelIntermediate to advanced
410 pages
9h 52m
English
Packt Publishing
Content preview from Practical Ansible 2

Creating your first machine

Now that Ansible is able to connect to your GCP environment, you can proceed with the actual Playbook:

  1. Create the gce.yaml Playbook with the following content:
---- hosts: localhost  tasks:    - name: create a instance      gcp_compute_instance:        name: TestMachine        machine_type: n1-standard-1        disks:        - auto_delete: 'true'          boot: 'true'          initialize_params:            source_image: family/centos-7            disk_size_gb: 10        zone: eu-west1-c        auth_kind: serviceaccount        service_account_file: "~/sa.json"        state: present

Execute it with the following command:

$ ansible-playbook gce.yaml

This will create an output like the following one:

PLAY [localhost] **********************************************************************************TASK [Gathering Facts] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Ansible - Third Edition

Mastering Ansible - Third Edition

James Freeman, Jesse Keating
Security Automation with Ansible 2

Security Automation with Ansible 2

Akash Mahajan, MADHU AKULA

Publisher Resources

ISBN: 9781789807462Supplemental Content