【问题标题】:Rundeck - problem with running commands/jobs with nodes defined in resource-yaml fileRundeck - 使用资源 yaml 文件中定义的节点运行命令/作业的问题
【发布时间】:2023-03-22 14:40:01
【问题描述】:

[已解决 - 在 cmets 中回答]

我正在寻求帮助。也许有人已经遇到了这个问题,或者只是知道发生了什么并且可以提供建议?非常感谢!

在 Rundeck 中,我定义了将 Ansible(通过 ansible 插件)设置为执行程序的项目。 在一个项目中,我有两个资源模型:

  • Ansible 资源模型源(Satellite 设置为动态清单 - 一切正常)
  • resourceyaml(不工作

本文末尾列出了这两种资源的配置。

如前所述,我正在努力处理 yaml 资源模型中定义的节点 -

  • 节点在节点部分可见,但每当我尝试对其执行命令或作业时,都会引发错误:
[WARNING]: Could not match supplied host pattern, ignoring: template
ERROR! Specified hosts and/or --limit does not match any hosts
Failed: AnsibleError: ERROR: Ansible execution returned with non zero code.
Execution failed: 116 in project Linux-Ansible: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [template: AnsibleError: ERROR: Ansible execution returned with non zero code. + {dataContext=MultiDataContextImpl(map={}, base=null)} ]}, Node failures: {template=[AnsibleError: ERROR: Ansible execution returned with non zero code. + {dataContext=MultiDataContextImpl(map={}, base=null)} ]}, status: failed]

当我通过 cli 执行 ansible 并将 resourceyaml 文件设置为库存时,我可以看到以下警告:

ansible -i /etc/ansible/hosts-rundeck-static.yml all --limit node001@domain.com -m shell -a id
[WARNING]: Skipping key (username) in group (template) as it is not a mapping, it is a <class 'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: Skipping key (description) in group (template) as it is not a mapping, it is a <class
'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: Skipping key (tags) in group (template) as it is not a mapping, it is a <class 'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: Skipping key (hostname) in group (template) as it is not a mapping, it is a <class 'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: Skipping key (ssh-keypath) in group (template) as it is not a mapping, it is a <class
'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: Skipping key (nodename) in group (template) as it is not a mapping, it is a <class 'ansible.parsing.yaml.objects.AnsibleUnicode'>
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: node001@domain.com

会议。对于资源模型:

  1. YAML:
Format: resourceyaml
File Path:/etc/ansible/hosts-rundeck-static.yml
Writeable: yes 

hosts-rundeck-static.yml 的内容:

---
template:
 nodename: node001@domain.com
 hostname: 1.2.3.4
 username: admin@domain.com
 ssh-keypath: keys/ssh_key/key1
 description: this is a template node
 tags: template
  1. Ansible 库存:
ansible inventory File path:/etc/ansible/foreman.yml
Ansible config file path:/etc/ansible
Gather Facts: yes 
Ignore Host Discovery Errors: yes 
SSH Authentication: privateKey
SSH User:admin@domain.com
SSH Key File path:/rundeck/id_ecdsa
Privilege escalation method.: sudo 

Ansible 配置:

[defaults]
strategy_plugins = /opt/mitogen/ansible_mitogen/plugins/strategy
collections_paths = /etc/ansible/collections
inventory      = /etc/ansible/foreman.yml
timeout = 30
[inventory]
enable_plugins = host_list, yaml, script, ini, foreman
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
pipelining = True
[persistent_connection]
[accelerate]
[selinux]
[colors]
[diff]

Rundeck 版本:3.3.6-20201111,带有 Ansible 插件版本:3.1.1

谁能帮我解决这个问题?谢谢!

【问题讨论】:

  • 嗨!您是否遵循本指南? stackoverflow.com/a/60019714/10426011 有了它,你可以同时使用两个模型源。
  • 另外,检查 YAML 语法,记住 YAML 格式是列敏感的(也用 XML 文件模型源而不是 YAML 进行测试)请看一下:docs.rundeck.com/docs/manual/document-format-reference/…
  • 嘿 MegaDrive68k - 抱歉回复晚了!让我看看上面的文章,我会回复你的......
  • 我经历了stackoverflow.com/questions/60011639/… 并且成功了!在 resourceyaml 中定义的节点现在可以完全运行了!我的问题很简单——在“Ansible Ad-Hoc Node Executor”->“Ansible 配置文件路径”中——我配置了“/etc/ansible”,应该是“/etc/ansible/ansible.cfg”。感谢 MegaDrive68k 的提示!
  • 太棒了,好消息!

标签: ansible rundeck


【解决方案1】:

作为记录答案:遵循this 指南并在节点执行器部分正确定义ansible.cfg /inventory 路径(最后带有文件名)解决了这个问题。

【讨论】:

    猜你喜欢
    • 2023-02-08
    • 2017-01-19
    • 2022-01-18
    • 2023-03-12
    • 2013-05-29
    • 1970-01-01
    • 2020-02-19
    • 2017-05-01
    • 2016-10-06
    相关资源
    最近更新 更多