forked from Azure-Samples/ansible-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_create.yml
39 lines (37 loc) · 1.1 KB
/
sql_create.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Description
# ===========
# This playbook create a SQL server and an instance of SQL Database.
# Note: Random number is used to set a globally unique name for SQL Server
#
---
- hosts: localhost
tasks:
- name: Prepare random postfix
set_fact:
rpfx: "{{ 1000 | random }}"
run_once: yes
- hosts: localhost
vars:
resource_group: "{{ resource_group_name }}"
location: eastus
sqlserver_name: sqlansible{{ rpfx }}
sqldb_name: sqldbtest
admin_username: admxyz
admin_password: Abcpasswordxyz12!
tasks:
- name: Create a resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: "{{ location }}"
- name: Create SQL Server
azure_rm_sqlserver:
name: "{{sqlserver_name}}"
resource_group: "{{resource_group}}"
version: 12.0
admin_username: "{{admin_username}}"
admin_password: "{{admin_password}}"
- name: Create instance of SQL Database
azure_rm_sqldatabase:
resource_group: "{{resource_group}}"
server_name: "{{sqlserver_name}}"
name: "{{sqldb_name}}"