Rundeck 导入已存在的 Ansible 项目?

huangapple go评论69阅读模式
英文:

Rundeck import exist ansible project?

问题

有没有一种方法可以集成一个正在运行和运行中的Ansible项目,还是必须从头开始?

我有:
/inventory/hosts.ini
/roles/
role1
...
role 60

/playbook1
/playbook2

ansible.cfg
user:
path_key:

我想在圆角中使用这个。

我已经尝试过使用rd-cli,但我无法真正得到结果。当然,我可以创建一个项目(在一段时间前在网上找到):

# 安装 Rundeck CLI
sudo apt-get install rundeck-cli

# 设置 Rundeck API 密钥
export RD_TOKEN="rundeck-Api-code"

# 设置 Rundeck 服务器 URL
export RD_URL="http://rundeck_server_url:port"

# 设置项目名称
project_name="Your_Project_Name"

# 创建 Rundeck 项目
rd projects create -p $project_name -- \
    --project.label="Your Project Label" \
    --project.ssh-keypath=/home/rundeck/.ssh/id_rsa

# 配置资源模型源
rd projects configure update -p $project_name -- \
    --resources.source.1.type=url \
    --resources.source.1.config.url=/home/rundeck/projects/$project_name/resources.d

# 添加 SSH 密钥
# 设置 SSH 密钥文件路径
private_key_file_path="/path/to/ssh/key/file"

# 读取 SSH 密钥文件的内容
private_key=$(cat $private_key_file_path)

# 将密钥添加到 Rundeck 密钥存储中
curl -H "X-Rundeck-Auth-Token: $RD_TOKEN" -X POST --data "$private_key" \
     -H "Content-Type: application/octet-stream" \
     $RD_URL/api/27/storage/keys/rundeck

# 添加节点
# 设置节点信息
node_name="node1"
node_hostname="node_hostname"
node_username="node_username"

# 添加节点
cat > /home/rundeck/projects/$project_name/resources.d/$node_name.yaml << EOL
$node_name:
  nodename: $node_name
  hostname: $node_hostname
  description: ''
  username: $node_username
  osFamily: unix
  ssh-key-storage-path: keys/rundeck
EOL

但这对我没有帮助,或者我没有理解。

英文:

Is there a way to integrate a running and functioning Ansible project or do you have to start from scratch?

I have:
/inventory/hosts.ini
/roles/
role1
...
role 60

/playbook1
/playbook2

ansible.cfg
user:
path_key:

and i would like to use this in round corner.

I have already tried to work with the rd-cli but I can't really get a result. Sure, I can create a project (found it on www a while ago):

# Rundeck CLI installieren
sudo apt-get install rundeck-cli

# Rundeck API Key setzen
export RD_TOKEN=&quot;rundeck-Api-code&quot;

# Rundeck Server URL setzen
export RD_URL=&quot;http://rundeck_server_url:port&quot;

# Projektname festlegen
project_name=&quot;Ihr_Projektname&quot;

# Rundeck Projekt erstellen
rd projects create -p $project_name -- \
    --project.label=&quot;Ihr Projekt Label&quot; \
    --project.ssh-keypath=/home/rundeck/.ssh/id_rsa

# Ressourcenmodellquelle festlegen
rd projects configure update -p $project_name -- \
    --resources.source.1.type=url \
    --resources.source.1.config.url=/home/rundeck/projects/$project_name/resources.d

# SSH Schl&#252;ssel hinzuf&#252;gen
# Setzen Sie den Pfad zur SSH-Schl&#252;sseldatei
private_key_file_path=&quot;/pfad/zur/ssh/schl&#252;sseldatei&quot;

# Lesen Sie den Inhalt der SSH-Schl&#252;sseldatei
private_key=$(cat $private_key_file_path)

# F&#252;gen Sie den Schl&#252;ssel in den Rundeck Key Storage ein
curl -H &quot;X-Rundeck-Auth-Token: $RD_TOKEN&quot; -X POST --data &quot;$private_key&quot; \
     -H &quot;Content-Type: application/octet-stream&quot; \
     $RD_URL/api/27/storage/keys/rundeck

# Node hinzuf&#252;gen
# Node Informationen setzen
node_name=&quot;node1&quot;
node_hostname=&quot;hostname_des_nodes&quot;
node_username=&quot;benutzername_des_nodes&quot;

# Node hinzuf&#252;gen
cat &gt; /home/rundeck/projects/$project_name/resources.d/$node_name.yaml &lt;&lt; EOL
$node_name:
  nodename: $node_name
  hostname: $node_hostname
  description: &#39;&#39;
  username: $node_username
  osFamily: unix
  ssh-key-storage-path: keys/rundeck
EOL

but that does not help me or i didnt understood

答案1

得分: 1

你可以集成ansible项目,只需指向项目默认的节点执行器 / 文件复制器的ansible配置和清单文件,以及ansible 模型来源上的适当配置。

现在,要使用你的Ansible Playbooks,请创建指向它们的作业(在作业中添加内联Ansible Playbooks步骤或Ansible Playbook步骤)。

查看这个答案。

英文:

You can integrate ansible projects, just point the ansible config and inventory file on the project default node executor / file copier and the proper config on the ansible model source.

Now, to use your Ansible playbooks, create jobs that point to them (adding a inline ansible playbooks steps or ansible playbook steps on the job).

Check this answer.

huangapple
  • 本文由 发表于 2023年6月8日 16:37:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76430030.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定