Home > Storage > PowerFlex > White Papers > PowerFlex REST API Introduction > Playbook structure
Ansible playbooks are a list of tasks to be executed against a PowerFlex cluster. One or more tasks can be combined to make a play and two or more plays make a playbook. In the following example the playbook contains two plays. The first play uses the volume module and creates and maps a volume to an SDC in Site-A. The second play creates and maps a volume to an SDC, then creates a snapshot of the volume using the snapshot module.
The following is an example of a play to create and map a volume to an SDC.
#Play to create 256GB volume and map to SDC sdc1a
- name: Create and map PowerFlex volume to SDC
hosts: localhost
connection: local
gather_facts: False
vars:
hostname: pfmp1
username: 'admin'
password: 'password'
validate_certs: False
protection_domain_name: "pd1"
storage_pool_name: "sp1"
vol_name: "vol001"
collections:
- dellemc.powerflex
tasks:
- name: Create a volume
register: result
dellemc_powerflex_volume:
hostname: "{{hostname}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
vol_name: "{{vol_name}}"
storage_pool_name: "{{storage_pool_name}}"
protection_domain_name: "{{protection_domain_name}}"
sdc:
- sdc_name: "sdc1a"
allow_multiple_mappings: False
sdc_state: "mapped"
size: 256
state: "present"
The following is an example of two plays. The first play creates a 256GB volume and the second play creates a snapshot of the volume.
#Play to create 256GB volume
- name: Create volume and snapshot
hosts: localhost
connection: local
gather_facts: False
vars:
gateway_host: 'pfmp2'
username: 'admin'
password: 'password'
verifycert: False
collections:
- dellemc.powerflex
tasks:
- name: Create volume
dellemc_powerflex_volume:
gateway_host: "{{gateway_host}}"
username: "{{username}}"
password: "{{password}}"
verifycert: "{{verifycert}}"
vol_name: "vol002"
storage_pool_name: "sp1"
protection_domain_name: "pd1"
size: 256
state: "present"
#Play to create snapshot of vol002
- name: Create snapshot
register: result
dellemc_powerflex_snapshot:
gateway_host: "{{gateway_host}}"
username: "{{username}}"
password: "{{password}}"
verifycert: "{{verifycert}}"
snapshot_name: "snap1-vol002"
vol_name: "vol002"
state: "present"