Configuration management & automation — Azure · AWS · GCP
Ansible automates server configuration, application deployment, and cloud provisioning using agentless SSH and YAML playbooks. Cloud modules work across Azure, AWS, and GCP.
---
- name: Common VM setup
hosts: all
become: yes
vars:
app_user: myapp
app_dir: /opt/myapp
tasks:
- name: Install Docker
apt:
name: docker.io
state: present
update_cache: yes
- name: Create app user
user:
name: "{{ app_user }}"
state: present
groups: docker
- name: Start node_exporter
systemd:
name: prometheus-node-exporter
state: started
enabled: yes
- name: Deploy app config
template:
src: config.yml.j2
dest: "{{ app_dir }}/config.yml"# inventory.gcp.yml plugin: gcp_compute projects: - my-project filters: - labels.env = dev hostnames: - name keyed_groups: - key: labels.role auth_kind: serviceaccount service_account_file: /path/to/sa-key.json
# Dry run (check mode) ansible-playbook -i inventory.gcp.yml playbook.yml --check # Apply ansible-playbook -i inventory.gcp.yml playbook.yml # Limit to specific group ansible-playbook -i inventory.gcp.yml playbook.yml --limit "role_webserver" # Verify idempotency (second run should show changed=0) ansible-playbook -i inventory.gcp.yml playbook.yml