Skip to content

Commit

Permalink
add test case configuring ansible-inventory without explicit inventor…
Browse files Browse the repository at this point in the history
…y list file
  • Loading branch information
ltamaster committed Jul 15, 2024
1 parent b66be08 commit 6fa13c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import functional.base.BaseTestConfiguration
import org.testcontainers.spock.Testcontainers

@Testcontainers
class LargeInventorySpec extends BaseTestConfiguration {
class InventoryListSpec extends BaseTestConfiguration {

static String PROJ_NAME = 'ansible-large-inventory'

Expand All @@ -16,11 +16,11 @@ class LargeInventorySpec extends BaseTestConfiguration {
def "test large inventory"(){
when:

def result = client.apiCall {api-> api.listNodes(PROJ_NAME,".*")}
def result = client.apiCall {api-> api.listNodes(PROJ_NAME,"tags:test")}

then:
result!=null
result.size()==8001
result.size()==8000
result.get("Node-0")!=null
result.get("Node-0").getAttributes().get("ansible_host") == "ssh-node"
result.get("Node-0").getAttributes().get("ansible_ssh_user") == "rundeck"
Expand All @@ -30,4 +30,18 @@ class LargeInventorySpec extends BaseTestConfiguration {
result.get("Node-7999").getAttributes().get("ansible_ssh_user") == "rundeck"
result.get("Node-7999").getAttributes().get("some-var") == "1234"
}

def "test empty inventory path"(){
when:

def result = client.apiCall {api-> api.listNodes(PROJ_NAME,"tags:fake")}

then:
result!=null
result.size()==35
result.get("node1")!=null
result.get("node1").getAttributes().get("ansible_host") == "node1"
result.get("node1").getAttributes().get("ansible_user") == "agent"
result.get("node1").getAttributes().get("ansible_port") == "22"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- "4440"
volumes:
- ./ansible:/home/rundeck/ansible:rw
- ./ansible/ansible.cfg:/etc/ansible/ansible.cfg:rw
- ./ansible-list:/home/rundeck/ansible-list:rw

volumes:
rundeck-data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ resources.source.2.config.ansible-gather-facts=false
resources.source.2.config.ansible-ignore-errors=true
resources.source.2.config.ansible-inventory=/home/rundeck/ansible/large-inventory.py
resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
resources.source.3.config.ansible-config-file-path=/home/rundeck/ansible-list
resources.source.3.config.ansible-gather-facts=false
resources.source.3.config.ansible-ignore-errors=true
resources.source.3.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
service.FileCopier.default.provider=sshj-scp
service.NodeExecutor.default.provider=sshj-ssh

0 comments on commit 6fa13c5

Please sign in to comment.