Skip to content

Commit 7441d7d

Browse files
Britton, NicholasBritton, Nicholas
authored andcommitted
inital ansible
inital work posting to github. looking to work with the community and veritas on the ansible deployments. msdp_create and vmware_resourcelimits need some assitance. although it looks right from the swagger docs, it seems to through an api error.
1 parent ae62d52 commit 7441d7d

4 files changed

Lines changed: 209 additions & 0 deletions

File tree

snippets/ansible/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### NetBackup API Code Samples for Ansible
2+
3+
This directory contains code samples to invoke NetBackup REST APIs using ansible.
4+
5+
#### Disclaimer
6+
7+
These scripts are only meant to be used as a reference. If you intend to use them in production, use it at your own risk.
8+
9+
#### Pre-requisites:
10+
11+
- NetBackup 8.1.1 or higher
12+
- ansible 2.x
13+
14+
15+
#### Executing the snippets in ansible
16+
17+
These are tasks meant to be part of a larger playbook. I use them with the following syntax
18+
19+
tasks:
20+
-name: name of tasks
21+
include_task: tasklocation/taskname
22+
23+
24+
Vars for ansible are defined in a inventory file for use in plays
25+
vars created during plays are used in future ones like login.yml.

snippets/ansible/login.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- name: login
3+
uri:
4+
url: "{{baseurl}}login"
5+
method: POST
6+
body_format: json
7+
status_code: 201
8+
headers:
9+
content-type: application/vnd.netbackup+json;version=3.0
10+
body:
11+
userName: "{{username}}"
12+
password: "{{password}}"
13+
validate_certs: no
14+
return_content: yes
15+
register: login
16+
17+
- name: set facts
18+
set_fact:
19+
login_token: "{{login.json.token}}"
20+
- name: debug token
21+
debug:
22+
msg: "{{login_token}}"

snippets/ansible/msdp_create.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
- name: Create storage server
3+
uri:
4+
url: "{{baseurl}}storage/storage-servers"
5+
method: POST
6+
body_format: json
7+
status_code: 201, 409
8+
headers:
9+
authorization: "{{login.json.token}}"
10+
content-type: application/vnd.netbackup+json;version=3.0
11+
body:
12+
data:
13+
type: storageServer
14+
attributes:
15+
name: ams03nbumed01.svc.west.com
16+
storageCategory: MSDP
17+
mediaServerDetails:
18+
name: ams03nbumed01.svc.west.com
19+
encryptionEnabled: true
20+
msdpAttributes:
21+
storagePath: /mnt/msdp/vol0
22+
credentials:
23+
userName: msdp
24+
password: msdp
25+
validate_certs: no
26+
return_content: yes
27+
register: stgsvr_create
28+
- name: debug stgsvr_create
29+
debug:
30+
msg: "{{stgsvr_create}}"
31+
32+
- name: Create MSDP Disk Pool
33+
uri:
34+
url: "{{baseurl}}storage/disk-pools"
35+
method: POST
36+
body_format: json
37+
status_code: 201
38+
headers:
39+
authorization: "{{login.json.token}}"
40+
content-type: application/vnd.netbackup+json;version=3.0
41+
body:
42+
data:
43+
type: diskPool
44+
attributes:
45+
name: ams03nbumed01_dpm
46+
diskVolumes:
47+
name: PureDiskVolume
48+
maximumIoStreams:
49+
limitIoStreams: true
50+
streamsPerVolume: 75
51+
relationships:
52+
storageServers:
53+
data:
54+
type: storageServer
55+
id: PureDisk:ams03nbumed01.svc.west.com
56+
validate_certs: no
57+
return_content: yes
58+
register: dp_create
59+
- name: debug dp_Create
60+
debug:
61+
msg: "{{dp_create}}"
62+
63+
- name: Create MSDP Storage Unit
64+
uri:
65+
url: "{{baseurl}}storage/storage-units"
66+
method: POST
67+
body_format: json
68+
status_code: 201
69+
headers:
70+
authorization: "{{login.json.token}}"
71+
content-type: application/vnd.netbackup+json;version=3.0
72+
body:
73+
data:
74+
type: storageUnit
75+
attributes:
76+
name: ams03nbumed01_dpm_su
77+
useAnyAvailableMediaServer: ture
78+
maxFragmentSizeMegabytes: 51200
79+
maxConcurrentJobs: 100
80+
onDemandOnly: true
81+
relationships:
82+
diskPool:
83+
data:
84+
type: diskPool
85+
id: "{{dp_create.json.id}"
86+
validate_certs: no
87+
return_content: yes
88+
register: stu_create
89+
- name: debug stu_Create
90+
debug:
91+
msg: "{{stu_Create}}"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
3+
---
4+
- name: vmware resource limits - vCenter
5+
uri:
6+
url: "{{baseurl}}config/resource-limits"
7+
method: POST
8+
body_format: json
9+
status_code: 201
10+
headers:
11+
authorization: "{{login.json.token}}"
12+
content-type: application/vnd.netbackup+json;version=3.0
13+
body:
14+
data:
15+
type: resource-limits
16+
attributes:
17+
resources:
18+
resourceType: vCenter
19+
resourceLimit: 50
20+
validate_certs: no
21+
return_content: yes
22+
register: vmware_resource
23+
- name: debug vmware_resource
24+
debug:
25+
msg: "{{vmware_resource}}"
26+
27+
- name: vmware resource limits - ESXserver
28+
uri:
29+
url: "{{baseurl}}config/resource-limits"
30+
method: POST
31+
body_format: json
32+
status_code: 201
33+
headers:
34+
authorization: "{{login.json.token}}"
35+
content-type: application/vnd.netbackup+json;version=3.0
36+
body:
37+
data:
38+
type: resource-limits
39+
attributes:
40+
resources:
41+
resourceType: ESXserver
42+
resourceLimit: 2
43+
validate_certs: no
44+
return_content: yes
45+
register: vmware_resource
46+
- name: debug vmware_resource
47+
debug:
48+
msg: "{{vmware_resource}}"
49+
50+
- name: vmware resource limits - Datastore
51+
uri:
52+
url: "{{baseurl}}config/resource-limits"
53+
method: POST
54+
body_format: json
55+
status_code: 201
56+
headers:
57+
authorization: "{{login.json.token}}"
58+
content-type: application/vnd.netbackup+json;version=3.0
59+
body:
60+
data:
61+
type: resource-limits
62+
attributes:
63+
resources:
64+
resourceType: Datastore
65+
resourceLimit: 2
66+
validate_certs: no
67+
return_content: yes
68+
register: vmware_resource
69+
- name: debug vmware_resource
70+
debug:
71+
msg: "{{vmware_resource}}"

0 commit comments

Comments
 (0)