Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_mysqldatabase and azure_rm_postgresqldatabase collation and charset not working. #749

Closed
Vitals9367 opened this issue Feb 2, 2022 · 4 comments
Labels
has_pr PR fixes have been made medium_priority Medium priority

Comments

@Vitals9367
Copy link

Vitals9367 commented Feb 2, 2022

SUMMARY

Ansible does not set collation and charset in Azure. Azure just uses default database server options.

Ansible playbook config:

azure.azcollection.azure_rm_mysqldatabase:
resource_group: "{{ resource_group }}"
server_name: "{{ mysql_name }}"
name: "{{ servicedb_name }}"
collation: utf8_swedish_ci
charset: utf8

azure.azcollection.azure_rm_postgresqldatabase:
resource_group: "{{ resource_group }}"
server_name: "{{ postgresql_name }}"
name: "{{ servicedb_name }}"
charset: utf8
collation: fi-FI

Output in logs:

"invocation": {
"module_args": {
"ad_user": null,
"adfs_authority_url": null,
"api_profile": "latest",
"auth_source": "auto",
"cert_validation_mode": null,
"charset": "utf8",
"client_id": null,
"cloud_environment": "AzureCloud",
"collation": "utf8_swedish_ci",
"force_update": true,
"log_mode": null,
"log_path": null,
"name": "test-collation-ansible3",
"password": null,
"profile": null,
"secret": null,
"state": "present",
"subscription_id": null,
"tenant": null
}
},
"name": "test-collation-ansible3"

In Azure:

"charset": "latin1",
"collation": "latin1_swedish_ci",
"name": "test-collation-ansible3"
"type": "Microsoft.DBforMySQL/servers/databases"

...

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure.azcollection.azure_rm_mysqldatabase and azure_rm_postgresqldatabase

ANSIBLE VERSION
azcollections - latest version
ansible - 2.12.1
@hcherukuri
Copy link

I see a similar issue when I run the collection. It doen't set the charset. See the ansible code and log below. You can see the charset value is being skipped.

Anisble code:

- name: Create keycloak Database
  azure_rm_mariadbdatabase:
    resource_group: "resourcegroup_name"
    server_name: "name"
    name: "database"
    charset: "utf8"
    force_update: true

Log:

TASK [azure : Create keycloak Database] ******************************************************************************************************************************************************
changed: [localhost] => (item={'name': 'site1-database1', 'site': 'site1', 'role': 'database', 'resourcegroup_name': 'ansible-middileware-eastus-rg', 'resourcegroup_location': 'eastus', 'start_ip_address': '0.0.0.0', 'end_ip_address': '255.255.255.255', 'database': 'keycloak'})

@Fred-sun
Copy link
Collaborator

@Vitals9367 Sorry for not replying you in time. The API of azure_rm_sqldatabase. py currently only supports the parameter 'collation', but does not support charset. You can refer to the Settings below. 'azure_rm_postgresqldatabase.py', I will reply and fix it as soon as possible. Thank you very much!

- name: Create instance of SQL Server --- First
  azure_rm_sqlserver:
    resource_group: "{{ resource_group }}"
    name: "sqlsrv{{ random_postfix }}"
    location: eastus
    admin_username: mylogin
    admin_password: Password123!
    tags:
      aaa: bbb
  register: output
- name: Create instance of SQL Database and set I(collation=SQL_Latin1_General_CP1_CI_AS)
  azure_rm_sqldatabase:
    resource_group: "{{ resource_group }}"
    server_name: sqlsrv{{ random_postfix }}
    name: database{{ random_postfix }}
    location: eastus
    edition: premium
    collation: SQL_Latin1_General_CP1_CI_AS
    tags:
      aaa: bbb
  register: output
- name: Gather facts SQL Database and wait for restore point
  azure_rm_sqldatabase_info:
    resource_group: "{{ resource_group }}"
    server_name: sqlsrv{{ random_postfix }}
    name: database{{ random_postfix }}
  register: output
- name: Create instance of SQL Server -- Secondary
  azure_rm_sqlserver:
    resource_group: "{{ resource_group }}"
    name: "sqlsrv{{ random_postfix }}"
    location: eastus
    admin_username: mylogin
    admin_password: Password123!
    tags:
      aaa: bbb
  register: output

- name: Create instance of SQL Database and set I(collation=Latin1_General_CI_AI)
  azure_rm_sqldatabase:
    resource_group: "{{ resource_group }}"
    server_name: sqlsrv{{ random_postfix }}
    name: database{{ random_postfix }}
    location: eastus
    edition: premium
    collation: Latin1_General_CI_AI
    tags:
      aaa: bbb
  register: output
- name: Gather facts SQL Database and wait for restore point
  azure_rm_sqldatabase_info:
    resource_group: "{{ resource_group }}"
    server_name: sqlsrv{{ random_postfix }}
    name: database{{ random_postfix }}
  register: output

@Fred-sun
Copy link
Collaborator

fixes by #917

@Fred-sun Fred-sun added has_pr PR fixes have been made medium_priority Medium priority labels Jul 12, 2022
@Fred-sun
Copy link
Collaborator

fixes by #884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_pr PR fixes have been made medium_priority Medium priority
Projects
None yet
3 participants