-3

I have jar file that i want to deploy to diffrent hosts using ansible so i configured my inventory with the domains of my webapps

[webapps]
domainofwebapp1.com resource_group=RG web_app=WEBAPPname
domainofwebapp2.com resource_group=RG web_app=WEBAPPname
domainofwebapp3.com resource_group=RG web_app=WEBAPPname
domainofwebapp4.com resource_group=RG web_app=WEBAPPname

than i created a playbook to deploy via Az deploy as follow :

- name: Deploy JAR to Azure Web App
  hosts: webapps
  gather_facts: no
  tasks:
    - name: Run Azure login command
      shell: >
        az login --service-principal -u "clientID" -p "SECRET" --tenant "TEnantID"

    - name: Deploy JAR file to Azure Web App
      shell: >
        az webapp deploy --resource-group {{ hostvars[inventory_hostname].resource_group }} --name {{ hostvars[inventory_hostname].web_app }} --src-path "/path/to/your/local/jar/file.jar" --type jar

also i did configure ~/.azure/credentials

[default]
subscription_id=<subscription_id>
client_id=<service_principal_app_id>
secret=<service_principal_password>
tenant=<service_principal_tenant_id>

Yet i always get this error domainofwebapp1.com | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host domainofwebapp1.com port 22: Connection timed out", "unreachable": true }

I don't want to use SSH i want to configure it to not use ssh and use Service Principle instead

i tried also the az.collection azure_rm_webapp: module yet i couldn' deploy with it to the webapp it only help to create the web app .

CAN YOU HELP ME PLEASE TO DEPLOY SUCCEFULLY TO A GROUP OF AZURE WEBAPPS USING ANSIBLE .

1 Answer 1

0

It looks like you want to run this all locally, so there are a couple of different approaches you could take.

The first would be to delegate each task to run on your local host, using delegate_to: localhost in your tasks.

The second would be to remove those entries from your inventory and instead define them in a variable. You then just need to run your playbook on localhost and loop through your webapps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.