简体   繁体   中英

How to pass dynamic host ips in ansible playbook extension in azure devops

How to pass dynamic host ips in ansible playbook extension in azure devops. I am using Ansible extension in azure devops release pipeline and i want to pass dynamic list of IPs from a previous task in Host inventory.

First you need to define a variable and assign the list of IPs to it in the previous task. Then you can retrieve the list of IPs by referring to the variable in Ansible tasks.

Use expression "##vso[task.setvariable variable=IPs]ip1,ip2,ip3" to define a variable and assign value to it, Please check the official document . Below is an example to set the ips to the variable IPs in a powershell task.

在此处输入图片说明

Then you can use the variable like below example in Ansible task.

在此处输入图片说明

If the list of IPs is the output variables from previous you can directly refer to it using this expression $(<ReferenceName>.<VariableName>) . Check here for output variables. If the previous task didnot output the variable for IPs, then you need follow above steps to define a variable for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM