问题标签 [ansible-playbook]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
3787 浏览

git - Ansible sudo_user not using the correct $HOME directory

I have a git directory that is owned by a user that I cannot ssh as. I'm currently using sudo_user: user which is working but does not seem to be setting $HOME correctly. My user account has github in the ~/.ssh/known_hosts file but it is being added to my ~ssh_user/.ssh/known_hosts file (from the accept_hostkey=yes).

http://docs.ansible.com/git_module.html

Is there something I need to do to tell ansible to use $HOME correctly?

I'm running on Solaris off of Joyent but I don't think that's directly applicable to this problem.

0 投票
1 回答
7031 浏览

ansible - How to continue with the next file if one fails in Ansible playbook?

I have a main ansible playbook site.yml which includes three books one for webservers, one for dbservers, one for others.
Each has their own selection crietia specified in their own files e.g hosts:tag_name_webapp1 and similar. The issue is, if all hosts in web servers fail, ansible stops execution then and there. I want it to continue with the tasks in dbservers and so on.

0 投票
1 回答
1092 浏览

ansible - Ansible Playbook 中的变量变量

我正在尝试访问在group_vars

group_vars/全部

现在我正在传递parent这样的 ansible playbook extra vars 的细节

现在我如何访问vars中的parent1.child1值?parent1{{ parent }}

我的剧本看起来像这样:-

剧本.yml

剧本输出: -

任何人都可以指导我如何实现这个或任何替代解决方案。

0 投票
1 回答
2661 浏览

ansible - Group_by 未按预期匹配 ansible playbook 组 - 如何使用?

我无法弄清楚如何group_by在我的剧本中使用。我有一个受限于 RHEL6 的角色,我有兴趣了解如何group_by将 RHEL6 机器与 RHEL5 机器分开。我制作了一个复合键,在我的调试任务中我可以看到它已正确设置。但是即使调试任务吐出的复合键是“RedHat-6”,playbook 也会跳过该部分hosts: RedHat-6


(我的剧本中还有一个关于 RedHat-5 的部分,但它只是调用fail

我永远无法让 group_by 主机匹配,它总是跳过。输出如下所示:

我使用 group_by 是错误的还是误解了它的目的?我对ansible比较陌生;我使用的版本是 1.5.3。同样,我可以通过简单地以不同的方式验证来解决问题,但我想知道如何正确使用 group_by。预先感谢您的帮助!

0 投票
4 回答
4629 浏览

linux - Ansible 剧本

之前没用过Ansible,有谁知道怎么写一个简单的playbook卸载nano,在Linux服务器上安装vim?我想您需要包含一个选项来配置您在执行上述操作后想要的文本编辑器首选项。

干杯

编辑

这就是我到目前为止所得到的......

0 投票
1 回答
1021 浏览

npm - Ansible、npm 和 --save-dev 标志

我正在尝试使用 ansible 使用 karma-phantomjs-launcher 插件为詹金斯提供业力测试服务器。我希望避免使用“exec npm install”格式的shellscripts。

问题在于 phantomjs 插件需要--save-dev在安装时使用该标志。我正在寻找使用--save-devnpm 的标志,但 ansible npm 模块似乎没有办法将这些标志传递给它运行的实际 npm 命令。

这可能吗,还是我应该求助于使用 ansible 的命令模块来运行npm install karma-phantomjs-launcher --save-dev

0 投票
1 回答
449 浏览

ubuntu - 尝试安装 Edx 时出现 Ansible 代理错误

我试图按照这些说明安装 EdX https://github.com/edx/configuration/wiki/edX-Ubuntu-12.04-64-bit-Installation

但我总是卡在任务 [常见 | 添加 python-pycurl]

然后我收到了由 pip 引起的超时,由于 pip 没有收到我的代理设置。

那么如何将 https_proxy 环境变量全局传递给 ansible 上的每个任务呢?

谢谢

0 投票
3 回答
12648 浏览

ssh - How to use ansible with two factor authentication?

I have enabled two factor authentication for ssh using duosecurity (using this playbook https://github.com/CoffeeAndCode/ansible-duo ).

How can I use ansible to manage the server now. The SSH calls fail at gathering facts because of this. I want the person running the playbook to enter the two factor code before the playbook is run.

Disabling two factor for the deployment user is a possible solution but creates a security issue which I would I like to avoid.

0 投票
1 回答
7168 浏览

phpmyadmin - 如何通过 ansible 在 debian 上安装 phpmyadmin?

在 Debian 7.3 上,我通过 ansible playbook 安装了 nginx、mysql、php-fpm。

正常情况下,通过安装 PHPMyAdmin 时

它需要数据库密码,并进行一些配置。

现在要通过 ansible 创建一个安装和配置 PHPMyAdmin 的游戏,我该怎么办?

更新

我写了一个安装phpmyadmin的剧本。在安装过程中,它需要数据库用户名、密码和自己的帐户。所以搜索后我发现,ansible中有一个名为的模块debconf,它可以处理安装过程中的一些问题。像这样:

现在我想了解更多?关于安装和配置过程,?

0 投票
3 回答
137075 浏览

jinja2 - 如何在 Ansible playbook 中编写动态变量

基于extra vars参数我需要写变量值ansible playbook

如果只有param1通过

如果只有param1,param2通过

如果param1,param2,param3被传递,那么变量值将是

当我尝试通过模板动态创建变量时,我的剧本总是采用以前的变量值。但在 dest=roles/myrole/vars/main.yml其写作正确的价值。

我在这里尝试什么

所以在我创建的myroletemplate目录中vars

模板/myvar.j2

据我所知,如果只有两个条件,那么我可以使用inline expression如下方式执行此操作

<do something> if <something is true> else <do something else>

有没有可能if - elif - elseinline expression上面那样。或者在ansible playbook中动态分配价值的任何其他方式?