diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index 52c5155fb..b36707f5b 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -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)
diff --git a/tests/builders/fixtures/ansible-playbook001.xml b/tests/builders/fixtures/ansible-playbook001.xml
index 662321b3a..d19d6068c 100644
--- a/tests/builders/fixtures/ansible-playbook001.xml
+++ b/tests/builders/fixtures/ansible-playbook001.xml
@@ -13,6 +13,7 @@
false
+ false
5
true
false
diff --git a/tests/builders/fixtures/ansible-playbook002.xml b/tests/builders/fixtures/ansible-playbook002.xml
index 21c1ae0b8..afe136761 100644
--- a/tests/builders/fixtures/ansible-playbook002.xml
+++ b/tests/builders/fixtures/ansible-playbook002.xml
@@ -18,6 +18,7 @@ machine02.example.com
0421b950-487b-4749-aa69-d87425e14459
true
cloud-user
+ false
2
false
true
diff --git a/tests/builders/fixtures/ansible-playbook003.xml b/tests/builders/fixtures/ansible-playbook003.xml
index 314749252..8e15e776f 100644
--- a/tests/builders/fixtures/ansible-playbook003.xml
+++ b/tests/builders/fixtures/ansible-playbook003.xml
@@ -11,6 +11,7 @@
false
+ false
5
true
false
diff --git a/tests/builders/fixtures/ansible-playbook004.xml b/tests/builders/fixtures/ansible-playbook004.xml
new file mode 100644
index 000000000..bc4018bfb
--- /dev/null
+++ b/tests/builders/fixtures/ansible-playbook004.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ path/to/playbook.yml
+
+
+
+
+
+
+
+ false
+ true
+ cloud-user
+ 5
+ true
+ false
+ false
+
+ false
+
+
+
diff --git a/tests/builders/fixtures/ansible-playbook004.yaml b/tests/builders/fixtures/ansible-playbook004.yaml
new file mode 100644
index 000000000..528c839a1
--- /dev/null
+++ b/tests/builders/fixtures/ansible-playbook004.yaml
@@ -0,0 +1,7 @@
+---
+builders:
+ - ansible-playbook:
+ playbook: "path/to/playbook.yml"
+ inventory-type: "do-not-specify"
+ become: "yes"
+ become-user: "cloud-user"