Articles of ansible

Ansible:一个主机出现在多个共享父级的组中。 一个戏剧是为父母运行,它可以运行多次?

我有这个: [child1] host [child2] host [parent:children] child1 child2 和一个戏: – host: parent task: some_task 由于“child1”和“child2”具有相同的主机,该播放只运行一次。 但事实上,我希望它运行两次,每个孩子一次(因为在group_vars我有不同的variables为每个孩子)。 在儿童有不同的主机(比如我的“实验室”环境)的情况下,这种方法运行两次,但当主机是相同的时候(例如我的“testing”环境),这种方法不起作用。 我如何强制它运行两次(因为我真的需要它运行一次每个group_var文件)?

我如何从ec2主机获取ec2标签名称?

我想从EC2实例中提取“名称”标签。 我怎么做? 它似乎不是ec2_facts的一部分

与group_vars的ansible-playbook

我试图从ssh模型中组织可靠的拉。 之前我有一个像安装 group_vars/ all prod stage dev 现在我试图通过cron运行所有的东西,所以我尝试了这个设置 staging/ inventory group_vars/ server prod/ inventory group_vars/ server 库存上都是这样的 [server] localhost ansible_connection=local 为阶段我的group_vars看起来像 — rails_env: staging 我有一个例子玩 – hosts: server user: root sudo: no gather_facts: True tasks: – debug: msg="reading from {{ rails_env }}" 我的运行输出是 # ansible-playbook -i staging test.yml PLAY [server] ***************************************************************** GATHERING FACTS *************************************************************** ok: […]

不能从FC22机器上的星系安装

Ansible从github安装,根据安全网站的指示,似乎工作正常。 但是星系失败了: # ansible-galaxy -vvv install goozbach.epel Using /etc/ansible/ansible.cfg as config file Opened /home/alf/.ansible_galaxy Validate TLS certificates: True Connecting to galaxy_server: https://galaxy.ansible.com Base API: https://galaxy.ansible.com/api/v1 ERROR! Unexpected Exception: 'Galaxy' object has no attribute 'roles_paths' the full traceback was: Traceback (most recent call last): File "/opt/ansible/bin/ansible-galaxy", line 86, in <module> sys.exit(cli.run()) File "/opt/ansible/lib/ansible/cli/galaxy.py", line 153, in […]

在平衡主机上的完整副本

Ansible问题在这里。 我用vhost(ssl和non ssl)的模板构build了一个游戏。 这个vHost将被用于DEV,QUAL和Production服务器。 我有一个variables为每个envvariables文件。 然而,在生产中,我有2台服务器,显然,有2个不同的IP。 我如何设置具有2个variables的相同模板,并使用特定的variables集在每个服务器上进行推送。 我相信这很容易,但是我无法把思想包围起来。 谢谢。 ps:对不起我的英文写作不好。

错误,而玩耍的剧本

我只是安装在aws服务器上,然后创build一个剧本运行相同,但在运行时,我得到如下错误: ERROR! 'copy' is not a valid attribute for a Play The error appears to have been in '/root/amritha/pega-cloud-infrastructure/ansible/roles/datadog-pegalogs-apptier/tasks/main.yml': line 3, column 3, but may be elsewhere in the file depending on the exact syntax problem. 违规行似乎是: – name: copy the pattern_search.txt file which has patterns to be grepped ^ here 而我的剧本如下: – name: copy […]

无法获得pipe理windows系统工作的模块

我正在学习理智。 我的笔记本电脑正在运行Windows 7并且是域的一部分。 我已经在我的笔记本电脑的虚拟机内部安装了Ubuntu linux,并在其中安装了Ansible以及其他python和kerberos软件包。 也configuration了kerberos,但无法使用windows模块甚至使用win_ping来ping我的笔记本电脑。 Ansible我认为仍然试图使用ssh而不是winrm。 在group_vars / windows.yml文件中添加了用户和密码信息。 域名是lab.test.com 运行命令ansible laptop -m win_ping -vvvvv时得到的消息 Loaded callback minimal of type stdout, v2.0 <laptop.lab.test.com> ESTABLISH SSH CONNECTION FOR USER: None <laptop.lab.test.com> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s) <laptop.lab.test.com> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredA uthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no) <laptop.lab.test.com> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10) <laptop.lab.test.com> SSH: PlayContext set ssh_common_args: () <laptop.lab.test.com> […]

Windows Server 2012 R2不下载推荐的更新

我有多个运行在Azure上的Windows Server 2012 R2(IaaS VM)。 我们通过Ansible在这些服务器上执行月度维护,包括Windows更新(推荐和关键更新)。 这适用于我们90%以上的服务器,但有些服务器一直声称,他们从来没有任何要下载/安装的东西: 2016-06-07 13:09:14Z Creating Windows Update session… 2016-06-07 13:09:14Z Create Windows Update searcher… 2016-06-07 13:09:14Z Search criteria: (IsInstalled = 0 AND CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441') OR (IsInstalled = 0 AND CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4') 2016-06-07 13:09:14Z Searching for updates to install in category IDs 0FA1201D-4330-4FA8-8AE9-B877473B6441 E6CF1350-C01B-414D-A61F-263D14D133B4… 2016-06-07 13:10:51Z Creating update collection… […]

Ansible在多个主机上部署多个authorized_keys

我们需要在服务器上部署密钥,但诀窍是密钥很多,并不是所有服务器都必须部署。 现在我们这样做: 在variablesroles / authorized_keys / vars / main.yml中 ssh_users: – name: bob key: "{{ lookup('file', 'roles/authorized_keys/vars/bob.pub') }}" state: present – name: root key: "{{ lookup('file', 'roles/authorized_keys/vars/guru.pub') }}" state: present – name: root key: "{{ lookup('file', 'roles/authorized_keys/vars/user.pub') }}" state: absent 在任务: roles / authorized_keys / tasks / main.yml – name: Add ssh key. authorized_key: user={{ […]

用户是Ansible的本地variables吗?

users: – name: hellouser password: pw accessToken: "" readonly: false – name: hellouser2 password: pw2 accessToken: "" readonly: true 结果是: fatal: [IP]: FAILED! => {"changed": false, "failed": true, "msg": "AnsibleUndefinedVariable: 'unicode object' has no attribute 'name'"} 当users更改为users2 : users2: – name: hellouser password: pw accessToken: "" readonly: false – name: hellouser2 password: pw2 accessToken: "" […]