Add support for become in ansible playbook
Change-Id: Ia116f715042d4a4c8cc26ac45cf1a91be47435d3
This commit is contained in:
parent
497198a252
commit
45f2458584
@ -4460,6 +4460,11 @@ def ansible_playbook(parser, xml_parent, data):
|
||||
XML.SubElement(plugin, "sudoUser").text = data.get("sudo-user", "")
|
||||
else:
|
||||
XML.SubElement(plugin, "sudo").text = "false"
|
||||
if data.get("become", False):
|
||||
XML.SubElement(plugin, "become").text = "true"
|
||||
XML.SubElement(plugin, "becomeUser").text = data.get("become-user", "")
|
||||
else:
|
||||
XML.SubElement(plugin, "become").text = "false"
|
||||
XML.SubElement(plugin, "forks").text = str(data.get("workers", "5"))
|
||||
XML.SubElement(plugin, "unbufferedOutput").text = str(
|
||||
data.get("unbuffered-output", True)
|
||||
|
@ -13,6 +13,7 @@
|
||||
<credentialsId/>
|
||||
<vaultCredentialsId/>
|
||||
<sudo>false</sudo>
|
||||
<become>false</become>
|
||||
<forks>5</forks>
|
||||
<unbufferedOutput>true</unbufferedOutput>
|
||||
<colorizedOutput>false</colorizedOutput>
|
||||
|
@ -18,6 +18,7 @@ machine02.example.com
|
||||
<vaultCredentialsId>0421b950-487b-4749-aa69-d87425e14459</vaultCredentialsId>
|
||||
<sudo>true</sudo>
|
||||
<sudoUser>cloud-user</sudoUser>
|
||||
<become>false</become>
|
||||
<forks>2</forks>
|
||||
<unbufferedOutput>false</unbufferedOutput>
|
||||
<colorizedOutput>true</colorizedOutput>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<credentialsId/>
|
||||
<vaultCredentialsId/>
|
||||
<sudo>false</sudo>
|
||||
<become>false</become>
|
||||
<forks>5</forks>
|
||||
<unbufferedOutput>true</unbufferedOutput>
|
||||
<colorizedOutput>false</colorizedOutput>
|
||||
|
24
tests/builders/fixtures/ansible-playbook004.xml
Normal file
24
tests/builders/fixtures/ansible-playbook004.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>
|
||||
<playbook>path/to/playbook.yml</playbook>
|
||||
<inventory class="org.jenkinsci.plugins.ansible.InventoryDoNotSpecify"/>
|
||||
<limit/>
|
||||
<tags/>
|
||||
<skippedTags/>
|
||||
<startAtTask/>
|
||||
<credentialsId/>
|
||||
<vaultCredentialsId/>
|
||||
<sudo>false</sudo>
|
||||
<become>true</become>
|
||||
<becomeUser>cloud-user</becomeUser>
|
||||
<forks>5</forks>
|
||||
<unbufferedOutput>true</unbufferedOutput>
|
||||
<colorizedOutput>false</colorizedOutput>
|
||||
<hostKeyChecking>false</hostKeyChecking>
|
||||
<additionalParameters/>
|
||||
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
|
||||
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>
|
||||
</builders>
|
||||
</project>
|
7
tests/builders/fixtures/ansible-playbook004.yaml
Normal file
7
tests/builders/fixtures/ansible-playbook004.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
builders:
|
||||
- ansible-playbook:
|
||||
playbook: "path/to/playbook.yml"
|
||||
inventory-type: "do-not-specify"
|
||||
become: "yes"
|
||||
become-user: "cloud-user"
|
Loading…
Reference in New Issue
Block a user