rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
331 stars 100 forks source link

Nodes does not populate - using ansible plugin #99

Closed thakurmhn closed 7 years ago

thakurmhn commented 7 years ago

I am trying to test Rundeck with ansible plugin but Rundeck nodes are not getting populated after creating project, spent good amount of time and read almost all threads but not sure where I am making mistake, ansible-hosts4279533378978426335 is getting created with root permissions, I am able to see host name in temp directory /tmp/rundeck/ansible-hosts4279533378978426335/data/ however Node is not visible in Rundeck web console Not using become_user root in ansible configuration or while creating project Appreciate any help to fix this issue

Env: rundeck-2.7.2-1.26.GA.noarch rundeck-config-2.7.2-1.26.GA.noarch ansible-2.2.1.0-1.el6.noarch CentOS release 6.8 ansible-plugin-2.0.2 Java 1.8

[root@server2 rundeck]# ll ansible-hosts4279533378978426335/ total 12 drwxr-xr-x 2 root root 4096 Feb 26 21:47 data -rw-rw-r-- 1 rundeck rundeck 253 Feb 26 21:47 gather-hosts.yml -rw-rw-r-- 1 rundeck rundeck 52 Feb 26 21:47 host-tpl.j2

[root@server2 rundeck]# ll ansible-hosts4279533378978426335/data/ total 4 -rw-r--r-- 1 root root 665 Feb 26 21:47 ppclient.mhn.com

[root@server2 rundeck]# cat ansible-runner4658918977839836936extra-vars facts: False

project.properties file:

project.ansible-executable=/bin/sh project.description=test project.name=mhntest3 project.nodeCache.delay=30 project.nodeCache.enabled=true resources.source.1.config.ansible-become=false resources.source.1.config.ansible-gather-facts=false resources.source.1.config.ansible-ignore-errors=false resources.source.1.config.ansible-inventory=/etc/ansible/hosts resources.source.1.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory service.FileCopier.default.provider=com.batix.rundeck.plugins.AnsibleFileCopier service.NodeExecutor.default.provider=com.batix.rundeck.plugins.AnsibleNodeExecutor

service.log

WARN LoggingResourceModelSourceCache: [ResourceModelSource: 1.source (Ansible Resource Model Source), project: mhntest3] Returning cached model data INFO ProjectManagerService: Loading project definition for mhntest3... INFO ProjectManagerService: Loaded project mhntest3 in 27ms Using /etc/ansible/ansible.cfg as config file

PLAY [all] *****

TASK [file] **** changed: [ppclient.mhn.com -> localhost] => {"changed": true, "gid": 0, "group": "root", "mode": "0755", "owner": "root", "path": "/tmp/rundeck/ansible-hosts905265899853093168/data", "size": 4096, "state": "directory", "uid": 0}

TASK [template] **** changed: [ppclient.mhn.com -> localhost] => {"changed": true, "checksum": "2154ebf5658e6b858ab74db7c8228fa8ddb8b3f9", "dest": "/tmp/rundeck/ansible-hosts905265899853093168/data/ppclient.mhn.com", "gid": 0, "group": "root", "md5sum": "cd21f6f1edc88188ec133bed98eda35e", "mode": "0644", "owner": "root", "size": 663, "src": "/var/lib/rundeck/.ansible/tmp/ansible-tmp-1488127165.05-245634830373441/source", "state": "file", "uid": 0}

PLAY RECAP ***** ppclient.mhn.com : ok=2 changed=2 unreachable=0 failed=0

ERROR ExceptionCatchingResourceModelSource: [ResourceModelSource: 1.source (Ansible Resource Model Source), project: mhntest3] com.dtolabs.rundeck.core.resources.ResourceModelSourceException: Error deleting temporary directory. at com.batix.rundeck.plugins.AnsibleResourceModelSource.getNodes(AnsibleResourceModelSource.java:409) at com.dtolabs.rundeck.core.resources.ExceptionCatchingResourceModelSource.getNodes(ExceptionCatchingResourceModelSource.java:57) at com.dtolabs.rundeck.core.common.ProjectNodeSupport.getNodeSet(ProjectNodeSupport.java:108) at com.dtolabs.rundeck.core.common.ProjectNodeSupport$ProjectNodesSource.getNodes(ProjectNodeSupport.java:308) at com.dtolabs.rundeck.core.resources.ExceptionCatchingResourceModelSource.getNodes(ExceptionCatchingResourceModelSource.java:57) at com.dtolabs.rundeck.core.resources.ResourceModelSource$getNodes.call(Unknown Source) at rundeck.services.nodes.CachedProjectNodes.reloadNodeSet(CachedProjectNodes.groovy:42) at rundeck.services.nodes.CachedProjectNodes$reloadNodeSet.call(Unknown Source) at rundeck.services.NodeService$_loadNodes_closure3.doCall(NodeService.groovy:248) at rundeck.services.NodeService$_loadNodes_closure3.doCall(NodeService.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure.call(Closure.java:417) at com.codahale.metrics.Timer.time(Timer.java:99) at com.codahale.metrics.Timer$time$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at com.codahale.metrics.Timer$time$0.call(Unknown Source) at MetricswebGrailsPlugin$_addDynamicMetricMethods_closure26.doCall(MetricswebGrailsPlugin.groovy:190) at sun.reflect.GeneratedMethodAccessor413.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at org.codehaus.groovy.runtime.metaclass.ClosureStaticMetaMethod.invoke(ClosureStaticMetaMethod.java:59) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:230) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:96) at rundeck.services.NodeService.loadNodes(NodeService.groovy:260) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:80) at rundeck.services.NodeService.this$dist$invoke$1(NodeService.groovy) at rundeck.services.NodeService$2.methodMissing(NodeService.groovy) at sun.reflect.GeneratedMethodAccessor786.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:933) at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1256) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1209) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:807) at rundeck.services.NodeService$2.invokeMethod(NodeService.groovy) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1166) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) at rundeck.services.NodeService$_2_reload_closure1.doCall(NodeService.groovy:112) at rundeck.services.NodeService$_2_reload_closure1.doCall(NodeService.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure.call(Closure.java:417) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:251) at java.lang.Thread.run(Thread.java:745) Caused by: java.nio.file.AccessDeniedException: /tmp/rundeck/ansible-hosts905265899853093168/data/ppclient.mhn.com at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:244) at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) at java.nio.file.Files.delete(Files.java:1126) at com.batix.rundeck.plugins.AnsibleResourceModelSource$1.visitFile(AnsibleResourceModelSource.java:398) at com.batix.rundeck.plugins.AnsibleResourceModelSource$1.visitFile(AnsibleResourceModelSource.java:395) at java.nio.file.Files.walkFileTree(Files.java:2670) at java.nio.file.Files.walkFileTree(Files.java:2742) at com.batix.rundeck.plugins.AnsibleResourceModelSource.getNodes(AnsibleResourceModelSource.java:395) ... 85 more WARN LoggingResourceModelSourceCache: [ResourceModelSource: 1.source (Ansible Resource Model Source), project: mhntest3] Returning cached model data

thakurmhn commented 7 years ago

This is resolved by using following Project configuration

Mon Feb 27 21:08:15 IST 2017

edit below

project.description=Test Project project.name=TestProject project.nodeCache.delay=30 project.nodeCache.enabled=true project.ssh-authentication=privateKey project.ssh-keypath=/var/lib/rundeck/.ssh/id_rsa resources.source.1.config.ansible-become=false resources.source.1.config.ansible-gather-facts=false resources.source.1.config.ansible-ignore-errors=false resources.source.1.config.ansible-inventory=/etc/ansible/hosts resources.source.1.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory service.FileCopier.default.provider=jsch-scp service.NodeExecutor.default.provider=jsch-ssh

Later changed the Node Executor as Ansible-Ad-hoc and FileCopier as AnsibleFileCopier

xpufx commented 4 years ago

Based on my fresh experience trying to figure it out. What did it is the Gather Facts, false, stuff. Remove that and you'll see the hosts populated right away. However when you run a command you'll get new ssh related errors. That's why they weren't being populated in the first place.