我在我的ansible.cfg中定义了以下内容
# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
remote_user = ansible
然而,我有一个游戏手册bootstrap.yaml,在这里我与root而不是ansible连接。
---
- hosts: "{{ target }}"
become: no
gather_facts: false
remote_user: root
请先原谅我的问题。我已经搜索并花时间查看了How to iterate over inventory group in ansible?和Ansible iterate over hosts in inventory group set by variable风格的问题。 所以我会尽量保持问题的简单性。 清单看起来像这样:(这是为了更好地解释而改编的所有样本。) [GroupA]
host1 country=USA
host2 country=USA
host3 country=UK 因此,我希望只在没有主机的情况下传递Group,以便在每个主机上执行攻略。然而,作为剧本的一部分,首先我需要
我希望记住当前的剧本文件夹名,并将其传递给另一个导入的剧本。我将事实设置为"playbook_dir | basename",返回正确的文件夹名:应用程序。我把它作为bpm_folder传递给导入的剧本,它可以作为应用文件夹(调试返回:"msg": "appfolder")可见,但是它不能工作。
在我得到的进口剧本中:skipping vars_file '../{{ bpm_folder }}/deployment_settings.yml' due to an undefined variable.
但是,当我将vars添加到
我来告诉你我的情况。我有一个有两个服务器和两个剧本的主机文件。
我需要执行以下操作,首先我必须在服务器1号上运行一个剧本,如果没有错误,我需要在服务器2号上运行第二个剧本。我应该使用什么条件?
- name: Execute the First Play
import_playbook: first-playbook-to-run.yml
- name: Run the Second Playbook
import_playbook: second-playbook-to-run.yml
有什么帮助吗?致以敬意,
我正在尝试自动化一个复杂的部署。基本上:
我将一个新版本上传到一些服务器
运行测试脚本
在每个更新的服务器上验证结果
如果成功,请在下一批上重复。
目前这是手动完成的。
我有现有的剧本:
update.yml
start_test.sh #this one runs just locally so it does not need to be playbook
verify.yml
我很难用一本剧本来设置它。正如所说,将剧本导入tasks部分是不可能的。因此,这一点:
---
- hosts: all
gather_facts: no
serial: 3