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

Can't use restore_point_in_time in azure_rm_sqldatabase module #619

Closed
wohnout opened this issue Aug 27, 2021 · 0 comments · Fixed by #623
Closed

Can't use restore_point_in_time in azure_rm_sqldatabase module #619

wohnout opened this issue Aug 27, 2021 · 0 comments · Fixed by #623
Labels
has_pr PR fixes have been made medium_priority Medium priority

Comments

@wohnout
Copy link

wohnout commented Aug 27, 2021

SUMMARY

We are trying to do PITR recovery of Azure SQL database but we are not able to format restore_point_in_time argument. We tried:

restore_point_in_time: "2021-08-26 11:35:00"
restore_point_in_time: "{{ '2021-08-26 11:35:00' | to_datetime }}"
restore_point_in_time: "{{ ('2021-08-26 11:35:00' | to_datetime).isoformat() }}"

None of this were working

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure.azcollection.azure_rm_sqldatabase

ANSIBLE VERSION
ansible [core 2.11.4]
  config file = None
  configured module search path = ['/home/wohnout/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /home/wohnout/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True
COLLECTION VERSION
# /home/wohnout/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.8.0
CONFIGURATION
Empty
OS / ENVIRONMENT

Called from ubuntu 20.04 to Azure

STEPS TO REPRODUCE
- name: Creating PITR database
  azure_rm_sqldatabase:
    resource_group: "{{ azure_resource_group }}"
    create_mode: point_in_time_restore
    restore_point_in_time: "{{ ('2021-08-27 05:35:00' | to_datetime).isoformat() }}"
    source_database_id: "/subscriptions/{{ azure_subscription }}/resourceGroups/{{ azure_resource_group }}/providers/Microsoft.Sql/servers/{{ db_name }}/databases/test"
    server_name: "{{ db_name }}"
    name: test_PITR
    location: "{{ azure_resource_region }}"
EXPECTED RESULTS

task correctly processe

ACTUAL RESULTS
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: wohnout
<127.0.0.1> EXEC /bin/sh -c 'echo ~wohnout && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/wohnout/.ansible/tmp `"&& mkdir "` echo /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864 `" && echo ansible-tmp-1630051202.1023154-395-137801296321864="` echo /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.azure_rm_sqldatabase to azure.azcollection.azure_rm_sqldatabase
Using module file /home/wohnout/.ansible/collections/ansible_collections/azure/azcollection/plugins/modules/azure_rm_sqldatabase.py
<127.0.0.1> PUT /home/wohnout/.ansible/tmp/ansible-local-3902bclxy18/tmppdnf0zrx TO /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864/AnsiballZ_azure_rm_sqldatabase.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864/ /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864/AnsiballZ_azure_rm_sqldatabase.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864/AnsiballZ_azure_rm_sqldatabase.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/wohnout/.ansible/tmp/ansible-tmp-1630051202.1023154-395-137801296321864/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "ad_user": null,
            "adfs_authority_url": null,
            "api_profile": "latest",
            "append_tags": true,
            "auth_source": "auto",
            "cert_validation_mode": null,
            "client_id": null,
            "cloud_environment": "AzureCloud",
            "collation": null,
            "create_mode": "point_in_time_restore",
            "edition": null,
            "elastic_pool_name": null,
            "force_update": null,
            "location": "northeurope",
            "log_mode": null,
            "log_path": null,
            "max_size_bytes": null,
            "name": "test_PITR",
            "password": null,
            "profile": null,
            "read_scale": false,
            "recovery_services_recovery_point_resource_id": null,
            "resource_group": "resource-group",
            "restore_point_in_time": "2021-08-26T11:35:00",
            "sample_name": null,
            "secret": null,
            "server_name": "db-server-name",
            "sku": null,
            "source_database_deletion_date": null,
            "source_database_id": "/subscriptions/azure-subscription/resourceGroups/resource-group/providers/Microsoft.Sql/servers/db-server-name/databases/test",
            "state": "present",
            "subscription_id": null,
            "tags": null,
            "tenant": null,
            "zone_redundant": false
        }
    },
    "msg": "argument 'restore_point_in_time' is of type <class 'str'> and we were unable to convert to datetime: 'NoneType' object is not callable"
}
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
Development

Successfully merging a pull request may close this issue.

2 participants