Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions mysql_access.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Description
# ===========
# This playbook create a MySQL server and an instance of MySQL Database,

---
- hosts: localhost
vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the definition variable 'admin_password'.

resource_group: zimspostgresrg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to myTestResourceGroup

tasks:

- name: Query MySQL Servers in current resource group
azure_rm_mysqlserver_facts:
resource_group: "{{ resource_group }}"
register: os

- name: Dump MySQL Server facts
debug:
var: os

- name: Query MySQL Databases
azure_rm_mysqldatabase_facts:
resource_group: "{{ resource_group }}"
server_name: "{{ os.servers[0].name }}"
register: do

- name: Dump MySQL Database Facts
debug:
var: do

- name: Open firewall to access MySQL Server from outside
azure_rm_resource:
api_version: '2017-12-01'
resource_group: "{{ resource_group }}"
provider: dbformysql
resource_type: servers
resource_name: "{{ os.servers[0].name }}"
subresource:
- type: firewallrules
name: externalaccess
body:
properties:
startIpAddress: "0.0.0.0"
endIpAddress: "255.255.255.255"

- name: Dump tables
shell: mysql --host={{ os.servers[0].fully_qualified_domain_name }} --user={{ os.servers[0].admin_username }}@{{ os.servers[0].name }} --password={{ admin_password }} --verbose {{ item.name }} -e "show tables"
with_items: "{{ do.databases }}"
register: output

- debug:
var: output
6 changes: 3 additions & 3 deletions mysql_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#roles:
# - Azure.azure_preview_modules
vars:
resource_group: "{{ resource_group_name }}"
resource_group: zimspostgresrg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls rename resource group

location: eastus
mysqlserver_name: mysql{{ rpfx }}
mysqldb_name: sqldbtest
Expand All @@ -31,8 +31,8 @@
resource_group: "{{ resource_group }}"
name: "{{ mysqlserver_name }}"
sku:
name: GP_Gen4_2
tier: GeneralPurpose
name: B_Gen5_1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one is cheaper? pls use cheapest one

tier: Basic
location: "{{ location }}"
version: 5.6
enforce_ssl: True
Expand Down