如何在Windows中创建ansible星系角色? [英] How to create ansible galaxy roles in windows?

查看:106
本文介绍了如何在Windows中创建ansible星系角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过ancheible初学者从ansible初学者学习pros. Windows似乎不支持ansible.该书建议改为从虚拟机运行ansible.我使用流浪汉启动了一个VMbox,上面有ubuntu/trusty64.我可以在上面成功运行我的剧本.但是,在创建ansible-galaxy角色时遇到了一个问题.

I am learning ansible from ansible-beginner to pro by micheal heap. It seems that ansible is not supported on windows. The book suggests running ansible from a virtual machine instead. I started a VMbox using vagrant, which has ubuntu/trusty64 on it. I am successfully able to run my playbooks on it. However, I ran into an issue when creating ansible-galaxy roles.

我找不到在Windows上创建/初始化角色的方法.我从这个问题中隐约地借鉴了想法如何自动安装Ansible Galaxy角色?,并将以下命令添加到我的剧本中,以便在Windows上创建角色 local_action: command ansible-galaxy init sush.util --init-path roles

I could not find a way to create/ initialize a role on windows. I vaguely borrowed ideas from this question How to automatically install Ansible Galaxy roles? and added the following command to my playbook create roles on windows local_action: command ansible-galaxy init sush.util --init-path roles

---
- hosts: all
  gather_facts: false
  become: true
  tasks:
    - name: make sure we can connect
      ping:
    #ansible-galaxy
    - name: Init sush.util
      local_action: command ansible-galaxy init sush.util --init-path roles
      ignore_errors: true

如果角色已经创建,我还添加了ignore_errors=true来忽略错误. 这是正确的方法还是在Windows中有其他/更好的方法呢?

I also added ignore_errors=true to ignore the errors if the role has already been created. Is this the correct approach or is there another/better to do this in windows ?

推荐答案

如果您的目标是在Windows本地创建角色,则实际上不需要使用Ansible Galaxy来做到这一点. Ansible角色只是一组文件夹.要创建sush.util角色,请创建一个名为sush.util的文件夹,然后在其中创建以下文件夹:

If your aim is to create a role locally on Windows, you don't actually need to use Ansible Galaxy to do that. An Ansible role is just a set of folders. To create a sush.util role, create a folder named sush.util and then create the following folders inside that:

  • 任务
  • 处理程序
  • 模板
  • 文件
  • vars

最后,在每个文件夹中创建一个名为main.yml的文件,该文件的顶部包含---.

Finally, inside each of these folders create a file named main.yml that contains --- at the top.

您现在具有可以运行的Ansible角色.您添加到tasks/main.yml的所有任务都将执行.

You now have an Ansible role that you can run. Any tasks you add to tasks/main.yml will be executed.

这篇关于如何在Windows中创建ansible星系角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆