所有我的Ansible剧本/角色都签入我的git仓库.
但是,对于Ansible Galaxy角色,我总是必须在我想运行Ansible的每台机器上逐个明确地下载它们.
在Ansible抱怨在运行时缺少角色之前,确切地知道确切需要哪些Ansible Galaxy角色甚至是很难的.
如何管理Ansible Galaxy角色依赖项?我想让他们检查我的git repo以及其余的ansible代码,或者在我在新机器上运行Ansible时自动识别和下载它们.
所以我想我应该尽可能开始使用Ansible Galaxy,而不是自己编写角色.我刚刚安装了我的第一个角色,它已安装到/etc/local/ansible/roles
(我在OSX上).现在我想知道你如何在我真正需要的地方安装这个角色?我只是将角色复制到我需要的地方,还是有一种Ansible方式可以做到这一点?
当我尝试安装ansible角色时,我看到了这个异常.
$ ansible-galaxy install zzet.postgresql
Traceback (most recent call last):
File "/Users/myHomeDir/.homebrew/Cellar/ansible/1.4.3/libexec/bin/ansible-galaxy", line 34, in <module>
import yaml
ImportError: No module named yaml
Run Code Online (Sandbox Code Playgroud)
操作系统:Mac Os Maverick
Ansible:1.4.3
有谁知道如何修理它?
我试图通过CLI在Mac OS X El Capitan上安装ansible-galaxy角色
$ ansible-galaxy install -r requirements.yml
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ERROR! Unexpected Exception: (setuptools 1.1.6 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python), Requirement.parse('setuptools>=11.3'))
the full traceback was:
Traceback (most recent call last):
File "/usr/local/bin/ansible-galaxy", line 73, in <module>
mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
File "/Library/Python/2.7/site-packages/ansible/cli/galaxy.py", line 38, in <module>
from ansible.galaxy.role import GalaxyRole
File "/Library/Python/2.7/site-packages/ansible/galaxy/role.py", line 35, in <module>
from ansible.playbook.role.requirement import RoleRequirement
File "/Library/Python/2.7/site-packages/ansible/playbook/__init__.py", line 25, in <module>
from ansible.playbook.play import Play
File "/Library/Python/2.7/site-packages/ansible/playbook/play.py", line 27, in <module>
from ansible.playbook.base import Base …
Run Code Online (Sandbox Code Playgroud) 开始学习 Ansible 并希望简化ansible-galaxy search nginx
命令,但我得到:
ERROR! Unknown error when attempting to call Galaxy at 'https://galaxy.ansible.com/api/api': <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>
Run Code Online (Sandbox Code Playgroud)
曾尝试使用ansible-galaxy --ignore-certs search nginx
但ansible-galaxy -c search nginx
现在正在寻找ansible-galaxy: error: unrecognized arguments: --ignore-certs
摊位。
操作系统:
发行商 ID:Ubuntu 描述:Ubuntu 18.04.5 LTS 版本:18.04 代号:bionic
安斯波版本:
ansible 2.9.5
config file = /home/maciej/projects/priv/ansible_nauka/packt_course/ansible.cfg
configured module search path = ['/home/maciej/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/maciej/.local/lib/python3.6/site-packages/ansible
executable location = /home/maciej/.local/bin/ansible
python version = 3.6.9 (default, Jul …
Run Code Online (Sandbox Code Playgroud) tl;dr
= OS X用户如何建议解决此权限错误?
我在OS X 10.10.1上,我最近安装了Ansible,运行以下内容:
sudo pip install ansible --quiet
sudo pip install ansible --upgrade
Run Code Online (Sandbox Code Playgroud)
我想从一个galaxy角色开始安装自制软件,并运行以下错误:
$ ansible-galaxy install geerlingguy.homebrew
- downloading role 'homebrew', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-homebrew/archive/1.0.1.tar.gz
- extracting geerlingguy.homebrew to /etc/ansible/roles/geerlingguy.homebrew
- error: you do not have permission to modify files in /etc/ansible/roles/geerlingguy.homebrew
- geerlingguy.homebrew was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.
Run Code Online (Sandbox Code Playgroud)
虽然我看到/etc
由root拥有,但我没有看到文档中的任何注释说我应该做chmod
任何事情.
以供参考:
$ ansible --version
ansible 1.8.2
configured module search …
Run Code Online (Sandbox Code Playgroud) 我有一组角色需要安装ansible-galaxy.
- src: 'https://gitlab.private/role-openstack-net.git'
scm: 'git'
version: '1.0.0'
name: 'role-openstack-net'
- src: 'https://gitlab.private/role-openstack-subnet.git'
scm: 'git'
version: '1.0.0'
name: 'role-openstack-subnet'
Run Code Online (Sandbox Code Playgroud)
在实际情况中,我有大约20个角色.
所有角色都是私有的,所以当我运行时:
ansible-galaxy install -f -c -r galaxy.yml
Run Code Online (Sandbox Code Playgroud)
它要求我为每个角色提供用户/通行证,这有点令人烦恼
手动,我这样做:
git config --global credential.helper store
Run Code Online (Sandbox Code Playgroud)
我输入我的凭证一次,然后它会记住它
但是我应该怎样做詹金斯的工作呢?
我在这里看到有一种放置令牌的方法:
https://github.com/ansible/ansible/pull/34621
但它似乎没有用.
任何的想法 ?
仅使用一个剧本,则Ansible无法自动安装从属角色.至少根据这个SO线程.
但是,我有使用Vagrant和Vagrant的Ansible本地配置器的额外"优势" .我可能申请的任何技巧?
的文档ansible-galaxy
说明如下:
ansible-galaxy 命令与 Ansible 捆绑在一起,您可以使用它从 Galaxy 或直接从基于 git 的 SCM 安装角色。您还可以使用它在 Galaxy 网站上创建新角色、删除角色或执行任务。
我试图弄清楚如何“直接从基于 git 的 SCM ”安装 Ansible 集合,如所示。当我ansible-galaxy collections --help
从 MacOS Catalina 上的 Ansible 2.9.1运行时,我看到以下内容:
usage: ansible-galaxy collection install [-h] [-s API_SERVER]
[--api-key API_KEY] [-c] [-v] [-f]
[-i] [-n | --force-with-deps]
[-p COLLECTIONS_PATH]
[-r REQUIREMENTS]
[collection_name [collection_name ...]]
positional arguments:
collection_name The collection(s) name or path/url to a tar.gz
collection artifact. This is mutually exclusive with
--requirements-file.
optional arguments:
-h, --help show this …
Run Code Online (Sandbox Code Playgroud) 每当我更改存储库中 Ansible 角色中的代码时,我还希望在测试计算机上的角色目录中更新该代码。我要做的就是获取新代码
ansible-galaxy remove rolename
ansible-galaxy install git+https://url/rolename
如果我在安装之前不使用删除选项,ansible-galaxy 就会跳过该角色,因为它已经安装了。它不会在存储库中看到已更改的文件。
实现这一目标的最佳方法是什么?
ansible-galaxy ×10
ansible ×9
ansible-role ×1
credentials ×1
git ×1
github ×1
jenkins ×1
macos ×1
osx-yosemite ×1
python ×1
roles ×1
ssl ×1
ubuntu-18.04 ×1
vagrant ×1
vagrantfile ×1