Azure / Ansible

Ansible Solution Template on Azure
MIT License
7 stars 10 forks source link

SQL Server does not allow for firewall update #21

Closed panoskarajohn closed 2 years ago

panoskarajohn commented 4 years ago

Hello community i am running the below ansible playbook through azure cloud shell. Also i get similar result from an Ubuntu 18.04.4 LTS with ansible 2.9.6. Steps to reproduce: 1) Go to Azure 2) Create a new Cloud Shell 3) Create a new *.yml file 4) Copy the below script. 5) Run like this

ansible-playbook name_of_your_playbook.yml

    vars:
      resource_group: ansibleResourceGroupName
      location: westeurope
      server_name: AnisbleDemoSqlServer
      database_name: AnsibleDemoSqlDatabase
    tasks:
     - name: Create (or update) SQL Server
       azure_rm_sqlserver:
        resource_group: "{{ resource_group }}"
        name: "{{ server_name }}"
        location: "{{ location }}"
        admin_username: panoskarajohn
        admin_password: Testpasswordxyz123

    - name: Create (or update) Firewall Rule
      azure_rm_sqlfirewallrule:
        resource_group: "{{ resource_group }}"
        server_name: "{{ server_name }}"
        name: firewallrule-allowall
        start_ip_address: 0.0.0.0
        end_ip_address: 255.255.255.255

My sqlserver is created. But the firewall rule fails, with an unauthorised error.

Also when i try to edit my sql server firewall's rules through the azure portal. Everything seems to be disabled.

When i create a new sql server through the portal, everything works.

Error i get:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating the Firewall Rule instance: 400 Client Error: Bad Request for url: -> Some url.

When i click on the url i get this json -> {"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}

Is there sth wrong with my playbook? Also how could i add to allow Azure Services to access this server?