Merge "Introduce disable-host-key-checking for builder ansible-playbook"

This commit is contained in:
Zuul 2020-05-26 12:11:22 +00:00 committed by Gerrit Code Review
commit 1ffef886f8
9 changed files with 59 additions and 7 deletions

View File

@ -4445,8 +4445,8 @@ def ansible_playbook(parser, xml_parent, data):
(default true)
:arg bool colorized-output: Check this box to allow ansible to render ANSI
color codes in the Jenkins console. (default false)
:arg bool host-key-checking: Check this box to enforce the validation of
the hosts SSH server keys. (default false)
:arg bool disable-host-key-checking: Check this box to disable the
validation of the hosts SSH server keys. (>= 1.0) (default false)
:arg str additional-parameters: Any additional parameters to pass to the
ansible command. (default '')
:arg list variables: List of extra variables to be passed to ansible.
@ -4457,6 +4457,12 @@ def ansible_playbook(parser, xml_parent, data):
* **value** (`str`) -- Desired value (default '')
* **hidden** (`bool`) -- Hide variable in build log (default false)
Outdated Options for versions >= 1.0 of plugin:
:arg bool host-key-checking: Outdated, replaced with disable-host-key-checking.
Check this box to enforce the validation of the hosts SSH server keys.
(< 1.0) (default true)
Example:
.. literalinclude::
@ -4468,6 +4474,12 @@ def ansible_playbook(parser, xml_parent, data):
.. literalinclude::
/../../tests/builders/fixtures/ansible-playbook002.yaml
:language: yaml
Example(s) versions < 1.0:
.. literalinclude::
/../../tests/builders/fixtures/ansible-playbook005.yaml
:language: yaml
"""
plugin = XML.SubElement(
xml_parent, "org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder"
@ -4528,8 +4540,11 @@ def ansible_playbook(parser, xml_parent, data):
XML.SubElement(plugin, "colorizedOutput").text = str(
data.get("colorized-output", False)
).lower()
XML.SubElement(plugin, "disableHostKeyChecking").text = str(
data.get("disable-host-key-checking", False)
).lower()
XML.SubElement(plugin, "hostKeyChecking").text = str(
data.get("host-key-checking", False)
data.get("host-key-checking", True)
).lower()
XML.SubElement(plugin, "additionalParameters").text = str(
data.get("additional-parameters", "")

View File

@ -17,7 +17,8 @@
<forks>5</forks>
<unbufferedOutput>true</unbufferedOutput>
<colorizedOutput>false</colorizedOutput>
<hostKeyChecking>false</hostKeyChecking>
<disableHostKeyChecking>false</disableHostKeyChecking>
<hostKeyChecking>true</hostKeyChecking>
<additionalParameters/>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
<extraVars>

View File

@ -22,6 +22,7 @@ machine02.example.com
<forks>2</forks>
<unbufferedOutput>false</unbufferedOutput>
<colorizedOutput>true</colorizedOutput>
<disableHostKeyChecking>false</disableHostKeyChecking>
<hostKeyChecking>true</hostKeyChecking>
<additionalParameters>-vvv</additionalParameters>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>

View File

@ -19,7 +19,6 @@ builders:
sudo-user: "cloud-user"
unbuffered-output: false
colorized-output: true
host-key-checking: true
additional-parameters: "-vvv"
variables:
- name: "complete_var"

View File

@ -15,7 +15,8 @@
<forks>5</forks>
<unbufferedOutput>true</unbufferedOutput>
<colorizedOutput>false</colorizedOutput>
<hostKeyChecking>false</hostKeyChecking>
<disableHostKeyChecking>true</disableHostKeyChecking>
<hostKeyChecking>true</hostKeyChecking>
<additionalParameters/>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>

View File

@ -3,3 +3,4 @@ builders:
- ansible-playbook:
playbook: "path/to/playbook.yml"
inventory-type: "do-not-specify"
disable-host-key-checking: true

View File

@ -16,7 +16,8 @@
<forks>5</forks>
<unbufferedOutput>true</unbufferedOutput>
<colorizedOutput>false</colorizedOutput>
<hostKeyChecking>false</hostKeyChecking>
<disableHostKeyChecking>false</disableHostKeyChecking>
<hostKeyChecking>true</hostKeyChecking>
<additionalParameters/>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>

View File

@ -0,0 +1,25 @@
<?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>
<disableHostKeyChecking>false</disableHostKeyChecking>
<hostKeyChecking>false</hostKeyChecking>
<additionalParameters/>
<copyCredentialsInWorkspace>false</copyCredentialsInWorkspace>
</org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder>
</builders>
</project>

View File

@ -0,0 +1,8 @@
---
builders:
- ansible-playbook:
playbook: "path/to/playbook.yml"
inventory-type: "do-not-specify"
become: "yes"
become-user: "cloud-user"
host-key-checking: false