Skip to content

Instantly share code, notes, and snippets.

@gowatana
Created July 28, 2024 13:50
Show Gist options
  • Save gowatana/0e0bec3b51a857dea62758115b779c05 to your computer and use it in GitHub Desktop.
Save gowatana/0e0bec3b51a857dea62758115b779c05 to your computer and use it in GitHub Desktop.
---
- name: Clone PostgreSQL DB
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <NDB IP>
nutanix_username: admin
nutanix_password: <NDB admin パスワード>
validate_certs: false
tasks:
- name: Get NDB Snapshots
ntnx_ndb_snapshots_info:
filters:
all : true
register: snapshots
- name: Set snap_id
set_fact:
snapshot_uuid: "{{ item.id }}"
loop: "{{ snapshots.response }}"
when: item.name == "snap-01"
- name: Output Snapshots ID
debug:
msg: "Snapshot ID: {{ snapshot_uuid }}"
- name: Clone DB from Snapshot
# https://galaxy.ansible.com/ui/repo/published/nutanix/ncp/content/module/ntnx_ndb_database_clones/#examples
ntnx_ndb_database_clones:
name: vectordb-clone-01
db_params_profile:
name: DEFAULT_POSTGRES_PARAMS
db_vm:
create_new_server:
name: vectordb-clone-vm-01
password: <VM NDB Drive ユーザのパスワード>
cluster:
name: EraCluster
network_profile:
name: DEFAULT_OOB_POSTGRESQL_NETWORK
compute_profile:
name: DEFAULT_OOB_SMALL_COMPUTE
pub_ssh_key: "ssh-rsa AAAAB3NzXXXXXXXXXXXXXXXXXXXXXXXXXXXXXTCKZVF"
postgres:
db_password: postgres
time_machine:
name: pgsql15-02_TM
snapshot_uuid: "{{snapshot_uuid}}"
register: result
- name: Output Result
debug:
msg: "{{result}}"
@gowatana
Copy link
Author

下記の投稿むけ。

NDB で PostgreSQL のクローン DB を作成してみる。(Ansible)
https://blog.ntnx.jp/entry/2024/07/28/234404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment