Skip to content

Commit

Permalink
Add tests for default true for encrypt extra vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Mar 29, 2024
1 parent aeb696e commit 9b6bc53
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class BasicIntegrationSpec extends Specification {

}

def "test inline playbook encrypt env vars"(){
def "test inline playbook encrypt env vars true"(){
when:

def jobId = "284e1a6e-bae0-4778-a838-50647fb340e3"
Expand All @@ -155,6 +155,37 @@ class BasicIntegrationSpec extends Specification {
Map<String, Integer> ansibleNodeExecutionStatus = TestUtil.getAnsibleNodeResult(logs)


then:
executionState!=null
executionState.getExecutionState()=="SUCCEEDED"
ansibleNodeExecutionStatus.get("ok")!=0
ansibleNodeExecutionStatus.get("unreachable")==0
ansibleNodeExecutionStatus.get("failed")==0
ansibleNodeExecutionStatus.get("skipped")==0
ansibleNodeExecutionStatus.get("ignored")==0
logs.findAll {it.log.contains("encryptVariable password")}.size() == 1
logs.findAll {it.log.contains("encryptVariable username")}.size() == 1
logs.findAll {it.log.contains("\"msg\": \"rundeck\"")}.size() == 1
logs.findAll {it.log.contains("\"msg\": \"demo\"")}.size() == 1

}
def "test inline playbook encrypt env vars default true"(){
when:

def jobId = "0f714bfb-a0a4-4668-8279-35a8c4167db9"

JobRun request = new JobRun()
request.loglevel = 'DEBUG'

def result = client.apiCall {api-> api.runJob(jobId, request)}
def executionId = result.id

def executionState = waitForJob(executionId)

def logs = getLogs(executionId)
Map<String, Integer> ansibleNodeExecutionStatus = TestUtil.getAnsibleNodeResult(logs)


then:
executionState!=null
executionState.getExecutionState()=="SUCCEEDED"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='password' secure='true' storagePath='keys/project/ansible-test/ssh-node.pass' valueExposed='true' />
<option name='username' value='rundeck' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankOrder>ascending</rankOrder>
<successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<group>Ansible</group>
<id>0f714bfb-a0a4-4668-8279-35a8c4167db9</id>
<loglevel>INFO</loglevel>
<name>simple-inline-playbook-encrypt-vars</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
<filter>name: ssh-node </filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<node-step-plugin type='com.batix.rundeck.plugins.AnsiblePlaybookInlineWorkflowNodeStep'>
<configuration>
<entry key='ansible-base-dir-path' value='/home/rundeck/ansible' />
<entry key='ansible-become' value='false' />
<entry key='ansible-extra-vars' value='password: ${option.password}&#10;username: ${option.username}&#10;test: "demo"' />
<entry key='ansible-playbook-inline' value='- hosts: all&#10; gather_facts: false&#10; tasks:&#10;&#10; - name: Get Disk Space&#10; shell: "df -h"&#10; register: sh_output&#10;&#10; - debug: var=sh_output.stdout_lines&#10; - debug: msg="{{ username }}"&#10; - debug: msg="{{ test }}" ' />
<entry key='ansible-ssh-auth-type' value='privateKey' />
<entry key='ansible-ssh-key-storage-path' value='keys/project/ansible-test/ssh-node.key' />
<entry key='ansible-ssh-passphrase-option' value='option.password' />
<entry key='ansible-ssh-use-agent' value='false' />
<entry key='ansible-ssh-user' value='rundeck' />
</configuration>
</node-step-plugin>
</command>
</sequence>
<uuid>0f714bfb-a0a4-4668-8279-35a8c4167db9</uuid>
</job>
</joblist>

0 comments on commit 9b6bc53

Please sign in to comment.