【发布时间】:2018-03-28 15:10:59
【问题描述】:
我正在通过 micheal heap 从 ansible-beginner 到 pro 学习 ansible。 Windows 上似乎不支持 ansible。这本书建议改为从虚拟机运行 ansible。我使用 vagrant 启动了一个 VMbox,上面有 ubuntu/trusty64。我能够成功地在它上面运行我的剧本。但是,我在创建 ansible-galaxy 角色时遇到了问题。
我找不到在 Windows 上创建/初始化角色的方法。我从这个问题How to automatically install Ansible Galaxy roles? 中隐约借用了一些想法,并将以下命令添加到我的剧本中 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 中有另一种/更好的方法?
【问题讨论】:
-
是的,可能代码没有明确目标。我想创建一个空角色结构,然后将任务添加到空角色内的 main.yml 文件中,然后我打算使用该角色。我在 VMBox 上有 ubuntu 操作系统,而不是在我的电脑上。我打算在虚拟机上安装 wordpress、nginx、php 等。我想在 windows 上的文件夹中为每个角色创建角色,并在每次安装组件时重复使用它们。
-
就这么做吧。我认为将 Ansible 用于人们通常使用的
vi或他们最喜欢的编辑器没有意义。 -
请解释你的答案。你说的我什么都不懂。在不使用 ansible 的情况下如何创建 ansible-galaxy 角色?这里的目的是学习ansible,而不是安装wordpress。我问如何在 windows 上创建一个空的 ansible Galaxy 角色?如果您不知道答案,请不要发布无用的无关cmets。
标签: windows ansible ansible-galaxy