How to use Azure DevOps server TFS Predefined Variable in My Ansible Playbook

0 votes

In my playbook, I'd like to use the Azure DevOps Predefine Variable "$(Build.SourcesDirectory)":

Here's my  playbook:

---
- hosts: KBR_MTL361
  tasks:
   - name: copy file
     win_copy:
      src: D:\Web.config
      dest: $(Build.SourcesDirectory)

I'm using Azure DevOps Pipeline to run this ansible-playbook:

Pipeline Task in TFS

However, it isn't working.

Is there anyone out there that knows how to use the pipeline variable?

Feb 9 in DevOps Tools by Edureka
• 840 points
192 views

1 answer to this question.

0 votes

Simply add your variables to the azure-pipelines as additional args. This is what yml looks like:

 - task: Ansible@0
      inputs:
        ansibleInterface: 'agentMachine'
        playbookPathOnAgentMachine: 'ansible/tfs_playbooks/install_agent.yml'
        inventoriesAgentMachine: 'file'
        inventoryFileOnAgentMachine: 'hosts.yml'
        args: '--extra-vars "build_source_dir=$(Build.SourcesDirectory) AGENT_URL=$(AGENT_URL)"'

The variables in your playbook can then be accessed:

---
- hosts: localhost
  tasks:
  - name: show debug
    debug:
      msg: "Dir {{ build_source_dir }} agent url {{AGENT_URL}}"
answered Feb 9 by Bhavitha
• 980 points

Related Questions In DevOps Tools

+1 vote
1 answer

i have a pyhton code in my git/git repository how to build that code in jenkins

Follow these steps @Bhaskar: Step 1: Open the Jenkins ...READ MORE

answered Oct 14, 2019 in DevOps Tools by Kalgi
• 52,350 points
298 views
0 votes
2 answers
0 votes
1 answer

how to fix the build with maven in bluemix

As per Bluemix Status Page today DevOps Delivery Pipeline ...READ MORE

answered Jul 6, 2018 in DevOps Tools by Kalgi
• 52,350 points
753 views
0 votes
1 answer

How to deploy Liberty packaged server automatic delivery

Here is a concept regarding your query. It ...READ MORE

answered Jul 11, 2018 in DevOps Tools by Atul
• 10,230 points
308 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,676 views
+2 votes
1 answer
0 votes
1 answer

Find PAT scope using azure DevOps rest api

At this time, there is no way ...READ MORE

answered Feb 11 in DevOps Tools by Bhavitha
• 980 points
160 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP