Skip to content

Commit 38636b5

Browse files
authored
Merge pull request #371 from rundeck-plugins/RUN-2524
RUN-2524: Ansible Resource Model with encrypted vault, using a vault password from the key storage
2 parents fadc2aa + 4bd25f1 commit 38636b5

File tree

7 files changed

+98
-1
lines changed

7 files changed

+98
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package functional
2+
3+
import functional.base.BaseTestConfiguration
4+
import org.testcontainers.spock.Testcontainers
5+
6+
@Testcontainers
7+
class EncryptedInventorySpec extends BaseTestConfiguration {
8+
9+
static String PROJ_NAME = 'ansible-encrypted-inventory'
10+
11+
def setupSpec() {
12+
startCompose()
13+
configureRundeck(PROJ_NAME)
14+
}
15+
16+
def "test encrypted inventory"(){
17+
when:
18+
19+
//wait for node to be available
20+
def result = client.apiCall {api-> api.listNodes(PROJ_NAME,".*")}
21+
22+
then:
23+
result!=null
24+
result.size()==4
25+
result.get("ssh-node")!=null
26+
result.get("ssh-node-1")!=null
27+
result.get("ssh-node-2")!=null
28+
}
29+
30+
31+
}

functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class BaseTestConfiguration extends Specification{
2222
public static final String NODE_USER_PASSWORD = "testpassword123"
2323
public static final String NODE_KEY_PASSPHRASE = "testpassphrase123"
2424
public static final String USER_VAULT_PASSWORD = "vault123"
25+
public static final String ENCRYPTED_INVENTORY_VAULT_PASSWORD = "123456"
2526

2627
def startCompose() {
2728
if(rundeckEnvironment==null){
@@ -106,6 +107,10 @@ class BaseTestConfiguration extends Specification{
106107
requestBody = RequestBody.create(USER_VAULT_PASSWORD.getBytes(), Client.MEDIA_TYPE_X_RUNDECK_PASSWORD)
107108
keyResult = client.apiCall {api-> api.createKeyStorage("project/$projectName/vault-user.pass", requestBody)}
108109

110+
//add encrypted inventory password
111+
requestBody = RequestBody.create(ENCRYPTED_INVENTORY_VAULT_PASSWORD.getBytes(), Client.MEDIA_TYPE_X_RUNDECK_PASSWORD)
112+
keyResult = client.apiCall {api-> api.createKeyStorage("project/$projectName/vault-inventory.password", requestBody)}
113+
109114
//create project
110115
def projList = client.apiCall(api -> api.listProjects())
111116

functional-test/src/test/groovy/functional/base/RundeckCompose.groovy

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class RundeckCompose extends DockerComposeContainer<RundeckCompose> {
3232
baseUrl rdUrl
3333
passwordAuth('admin', 'admin')
3434
logger(new TestLogger())
35+
timeout(300)
36+
readTimeout(300)
37+
connectTimeout(300)
3538
build()
3639
}
3740
return client
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
65366137663536643763393536326631663039653039323434663839323138653866376465653038
3+
3838363031653534376431396630623437383831636361380a326264346664613237383139343564
4+
61366565396261306238666230383366653438313234666363303165613235336637626532396431
5+
3465656235656238650a333137363333636435303934336434656630376637373763383830343566
6+
31333135653264643163653335643536616632303762396534663033373331613137663363336638
7+
30613632373765626662616437663162646265326133343865633430633735616663363638383263
8+
37333562663932386336316135356432346530666537373465653362623961643832353537336664
9+
39333331613431613735343066336334373964356131613163363630653338643061373961656563
10+
36343036623231646366313639383237303433376531306131656533633761613231336136643562
11+
62353330326165386433303064393435316363316236646437643431386436323530653366663238
12+
33343665313030623165633432393034393664376631393834666638316237633538626637633330
13+
37663761633234316330333232373365396235623361363262346634643764373834356434666236
14+
39393131666239346462613337663537643963343764396163353861663966653430323263366631
15+
64653436366564373130643963353864333763343330663039363465396231303461303937636161
16+
62613234383437353736343561363839376564326565626431363866653936653962623337363137
17+
64663738316637313133313463373261353038616461343236393537346235633336373766363563
18+
37613865303065653963376337643366313966386531616332363038613937653430303133323765
19+
33336363646332303432343362333638393134626138616664393363326161393639663438313031
20+
37643334336262396237376230313634383933643832333038373964373465306261323331343537
21+
37333530313466393933
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
by:
2+
urn: project:ansible-encrypted-inventory
3+
for:
4+
storage:
5+
- match:
6+
path: 'keys/.*'
7+
allow: [read]
8+
description: Allow access to key storage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Exported configuration
2+
project.description=
3+
project.disable.executions=false
4+
project.disable.schedule=false
5+
project.execution.history.cleanup.batch=500
6+
project.execution.history.cleanup.enabled=false
7+
project.execution.history.cleanup.retention.days=60
8+
project.execution.history.cleanup.retention.minimum=50
9+
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
10+
project.jobs.gui.groupExpandLevel=1
11+
project.label=
12+
project.later.executions.disable=false
13+
project.later.executions.enable=false
14+
project.later.schedule.disable=false
15+
project.later.schedule.enable=false
16+
project.name=encrypted-inventory-test
17+
project.nodeCache.enabled=true
18+
project.nodeCache.firstLoadSynch=true
19+
project.output.allowUnsanitized=false
20+
project.retry-counter=3
21+
project.ssh-authentication=privateKey
22+
resources.source.1.type=local
23+
resources.source.2.config.ansible-config-file-path=/home/rundeck/ansible
24+
resources.source.2.config.ansible-inventory=/home/rundeck/ansible/inventory-encrypted.ini
25+
resources.source.2.config.ansible-gather-facts=true
26+
resources.source.2.config.ansible-ignore-errors=true
27+
resources.source.2.config.ansible-vault-storage-path=keys/project/ansible-encrypted-inventory/vault-inventory.password
28+
resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
29+
service.FileCopier.default.provider=sshj-scp
30+
service.NodeExecutor.default.provider=sshj-ssh

src/main/groovy/com/rundeck/plugins/ansible/plugin/AnsibleResourceModelSource.java

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ public void configure(Properties configuration) throws ConfigurationException {
190190

191191
sshAgent = (String) resolveProperty(AnsibleDescribable.ANSIBLE_SSH_USE_AGENT,null,configuration,executionDataContext);
192192
sshPassphraseStoragePath = (String) resolveProperty(AnsibleDescribable.ANSIBLE_SSH_PASSPHRASE,null,configuration,executionDataContext);
193-
vaultPasswordPath = (String) resolveProperty(AnsibleDescribable.ANSIBLE_BECOME_PASSWORD_STORAGE_PATH,null,configuration,executionDataContext);
194193

195194
becamePasswordStoragePath = (String) resolveProperty(AnsibleDescribable.ANSIBLE_BECOME_PASSWORD_STORAGE_PATH,null,configuration,executionDataContext);
196195

0 commit comments

Comments
 (0)