Skip to content

Commit

Permalink
improve clone examples (#407)
Browse files Browse the repository at this point in the history
* imporve clone examples

* Fix Examples
  • Loading branch information
alaa-bish authored Oct 31, 2023
1 parent 7a9f51a commit 54d0bef
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 0 deletions.
121 changes: 121 additions & 0 deletions examples/ndb/create_clone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
- name: Create clone
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <ndb-era-ip>
nutanix_username: <username>
nutanix_password: <password>
validate_certs: false

tasks:
- set_fact:
clone_db:
name: <Clone Db Name>
db_params_profile:
name: <Db Profile Name>
vm:
name: <Vm Name>
password: <Vm password>
cluster:
name: <Cluster Name>
network_profile:
name: <Network Profile Name>
compute_profile:
name: <Compute Profile Name>
public_ssh_key: <Public SSH Key>
time_machine:
name: <Time Machine Name>
snapshot:
uuid: <Snapshot UUID>

- name: create clone using snapshot
ntnx_ndb_database_clones:
name: "{{clone_db.name}}"
desc: "ansible-created-clone"

db_params_profile:
name: "{{db_params_profile.name}}"

db_vm:
create_new_server:
name: "{{ vm.name }}"
desc: "vm for db server"
password: "{{ vm.password }}"
cluster:
name: "{{cluster.name}}"
network_profile:
name: "{{ network_profile.name }}"
compute_profile:
name: "{{ compute_profile.name }}"
pub_ssh_key: "{{ public_ssh_key }}"

postgres:
db_password: "{{vm.password}}"

time_machine:
name: "{{time_machine.name}}"
snapshot_uuid: "{{snapshot.uuid}}"

removal_schedule:
days: 2
timezone: "Asia/Calcutta"
remind_before_in_days: 1
delete_database: True

refresh_schedule:
days: 2
time: "12:00:00"
timezone: "Asia/Calcutta"

register: output

- debug:
msg: "{{output}}"

- name: create clone using point in time
ntnx_ndb_database_clones:
name: "{{clone_db.name}}"
desc: "ansible-created-clone"

db_params_profile:
name: "{{db_params_profile.name}}"

db_vm:
create_new_server:
name: "{{ vm.name }}"
desc: "vm for db server"
password: "{{ vm.password }}"
cluster:
name: "{{cluster.name}}"
network_profile:
name: "{{ network_profile.name }}"
compute_profile:
name: "{{ compute_profile.name }}"
pub_ssh_key: "{{ public_ssh_key }}"

postgres:
db_password: "{{vm.password}}"

time_machine:
name: "{{time_machine.name}}"
pitr_timestamp: "2023-02-28 12:00:00"
timestamp: "Asia/Calcutta"

removal_schedule:
days: 2
timezone: "Asia/Calcutta"
remind_before_in_days: 1
delete_database: True

refresh_schedule:
days: 2
time: "12:00:00"
timezone: "Asia/Calcutta"
register: output

- debug:
msg: "{{output}}"
40 changes: 40 additions & 0 deletions examples/ndb/refresh_clone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: Create Refresh clone
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <ndb-era-ip>
nutanix_username: <username>
nutanix_password: <password>
validate_certs: false

tasks:
- set_fact:
clone_db:
uuid: <Clone Db UUID>
snapshot:
uuid: <Snapshot UUID>

- name: create spec for refresh clone to a pitr timestamp
check_mode: yes
ntnx_ndb_database_clone_refresh:
uuid: "{{clone_db.uuid}}"
pitr_timestamp: "2023-02-04 07:29:36"
timezone: "UTC"
register: output


- debug:
msg: "{{output}}"

- name: refresh db clone
ntnx_ndb_database_clone_refresh:
uuid: "{{clone_db.uuid}}"
snapshot_uuid: "{{snapshot.uuid}}"
register: output

- debug:
msg: "{{output}}"

0 comments on commit 54d0bef

Please sign in to comment.