--- 
- name: "Transferring intial backup from DB2-A-HADR to DB2-B-HADR"
  synchronize: 
    delete: true
    dest: /local/
    src: /local/backup
- 
  name: "Setting DB2COMM to TCPIP"
  raw: "su - {{ db2usr }} -c 'db2set DB2COMM=TCPIP'"
- 
  name: "Stopping DB2"
  raw: "su - {{ db2usr }} -c 'db2stop force'"
- 
  name: "Starting DB2"
  raw: "su - {{ db2usr }} -c 'db2start'"
- 
  name: "Restoring {{ db2dbname }} from backup"
  raw: "su - {{ db2usr }} -c 'db2 restore db {{ db2dbname }} from /local/backup on /local/{{ database_dir }}'"
- 
  name: "Setting HADR_LOCAL_HOST to {{ db2_b_hadr_host }}"
  raw: "su - {{ db2usr }} -c 'db2 update db cfg for {{ db2dbname }} using HADR_LOCAL_HOST {{ db2_b_hadr_host }}'"
- 
  name: "Setting HADR_LOCAL_SVC to {{ db2_hadr_backend_ports }}"
  raw: "su - {{ db2usr }} -c 'db2 update db cfg for {{ db2dbname }} using HADR_LOCAL_SVC {{ db2_hadr_backend_ports }}'"
- 
  name: "Setting HADR_REMOTE_HOST to {{ db2_a_hadr_host }}"
  raw: "su - {{ db2usr }} -c 'db2 update db cfg for {{ db2dbname }} using HADR_REMOTE_HOST {{ db2_a_hadr_host }}'"
- 
  name: "Setting HADR_REMOTE_SVC to {{ db2_a_hadr_port }}"
  raw: "su - {{ db2usr }} -c 'db2 update db cfg for {{ db2dbname }} using HADR_REMOTE_SVC {{ db2_hadr_backend_ports }}'"
- 
  name: "Setting HADR_REMOTE_INST to {{ db2usr }}"
  raw: "su - {{ db2usr }} -c 'db2 update db cfg for {{ db2dbname }} using HADR_REMOTE_INST {{ db2usr }}'"
- 
  name: "Setting DB2-B-HADR to Standby"
  raw: "su - {{ db2usr }} -c 'db2 start hadr on db {{ db2dbname }} as standby'"
