- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
通过 fork 变量,我可以告诉 ansible 应该并行执行多少台主机。当之前的所有主机完成时,将执行下一个主机。如果主机上的执行时间不同,我必须等待最后一台主机完成。
是否可以告诉 ansible 在一个主机完成后开始下一个主机的下一个播放,而不是全部运行。
换句话说,我有数百个客户,播放时间为 5 分钟,而一些主持人需要 30 分钟。我们测试了 fork 的数量,发现 50 是一个很好的值。有时,接下来的 50 个必须等待一个主机 25 分钟。
最佳答案
Q: "Is it possible to tell Ansible to start the next play for one host after one has finished?"
答:是的。这是可能的。策略插件host_pinned是你要找的。引用:
Ansible will not wait for other hosts to finish the current task before queuing the next task for a host that has finished. Once a host is done with the play, it opens its slot to a new host that was waiting to start.
示例
让我们创建一个 list
shell> cat hosts
all:
hosts:
test_01:
wait_timeout: 1
test_02:
wait_timeout: 2
test_03:
wait_timeout: 3
test_06:
wait_timeout: 4
test_09:
wait_timeout: 5
下面的剧本
shell> cat pinned-01.yml
- name: Play A
hosts: all
gather_facts: false
strategy: host_pinned
tasks:
- debug:
msg: "A:{{ inventory_hostname }}
{{ lookup('pipe', 'date +%H-%M-%S') }}
started"
- wait_for:
timeout: "{{ wait_timeout }}"
- debug:
msg: "A:{{ inventory_hostname }}
{{ lookup('pipe', 'date +%H-%M-%S') }}
finished"
给予
shell> ansible-playbook pinned-01.yml -f 3 | grep msg\":
"msg": "A:test_06 15-33-05 started"
"msg": "A:test_09 15-33-05 started"
"msg": "A:test_01 15-33-05 started"
"msg": "A:test_01 15-33-08 finished"
"msg": "A:test_02 15-33-08 started"
"msg": "A:test_06 15-33-11 finished"
"msg": "A:test_03 15-33-11 started"
"msg": "A:test_02 15-33-11 finished"
"msg": "A:test_09 15-33-12 finished"
"msg": "A:test_03 15-33-15 finished"
结果
因为 -f 3
Ansible 启动了 3 个主机 (1,9,6)。主机 1 首先完成并向等待启动的新主机打开其插槽。主机 2 启动。与主机 6 完成后主机 3 立即启动的方式相同。主机 2 在主机 9 之后开始,在主机 9 之前完成。
关于ansible - 在完成一台主机而非所有 fork 主机后,为下一台主机执行 ansible 剧本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59877712/
我刚刚开始学习 Ansible 并且有一个关于什么定义“游戏”的问题。如果我在看一座寺庙,我的理解是戏剧通常从以下开始: - name: xxx hosts: yyy 我读过 姓名 : 关键字
我正在尝试从 Ansible 2.3.1.0 运行剧本。我的远程计算机是 RHEL7,Python 安装在/usr/bin/python 中。 我的剧本如下所示: --- - hosts: my-te
我正在使用主机文件在主机列表上运行一个 ansible 剧本: [consul] ${HOST1} ansible_ssh_host=${HOST1} ansible_ssh_user=devops
我以前没有使用过 Ansible,有谁知道如何编写一个简单的 playbook 来卸载 nano 并在 Linux 服务器上安装 vim?我想在完成上述操作后,您需要包含一个选项来配置您想要的文本编辑
我有一个包含多个主机的系统以确保可用性。我只需要在一台主机上运行我的 Ansible 剧本。但是,其中一些主机可能无法访问。假设我有 host1、host2、host3 ... 如果无法访问 host
我不断收到用户错误:(play)在剧本中。 Ansible 似乎在提示结肠,但我尝试的任何方法都不起作用。 - hosts: all become: root tasks: -name:
可能之前已经有人问过这个问题,但目前还找不到任何有用的东西。 我有这个任务: - name: Create folder if not exists win_file: path:
我想知道是否有人找到了一种解决方案,可以在库存组未定义或为空时避免显示任何警告。 我只想让剧本的一部分运行如果组存在并且不为空,如果不存在,跳过而不警告。 请阅读https://github.com/
我想知道是否有人找到了一种解决方案,可以在库存组未定义或为空时避免显示任何警告。 我只想让剧本的一部分运行如果组存在并且不为空,如果不存在,跳过而不警告。 请阅读https://github.com/
我有一个 python 应用程序调用下面的代码,计划通过 Ansible API 以编程方式运行 Ansible 剧本,而不是使用子进程之类的东西。 下面的代码运行但实际上似乎没有执行任何内容。抓取结
目前我的剧本结构是这样的: ~/test_ansible_roles ❯❯❯ tree . . ├── checkout_sources │ └── tasks │ └── main.
我有一个使用 Vagrant 创建并使用 Ansible 配置的 EC2 实例。 我有这个使用 apt 安装 2 个软件包的任务. --- - name: Install GIT & TIG ac
我对 SSH 服务器和 Ansible 很陌生,所以这可能是一个愚蠢的问题。 尝试运行 Ansible 剧本,同时使用下面的 bash 命令使用私钥访问服务器。 ansible-playbook db
我有一堆需要经常修补的服务器。我计划使用 Ansible 来协调修补过程。这里的要点是它必须是“全有或全无”修补。要么所有服务器都打补丁,要么没有。 我正在为我的剧本考虑的任务是这样的: 1 - 转到
当我表演时 ansible -i /home/linux/ansible/my-prereqs/hosts -m ping 'test' 172.16.57.101 | SUCCESS => {
我有以下剧本: - name: packagexx version check shell: apk version packagexx | awk 'NR>1{$1=$1;print}'
我想使用公共(public) aws key 对 .pem 文件来运行 ansible 剧本。我想在不更改我的 ~/.ssh/id_rsa.pub 的情况下执行此操作我无法从当前的 ~/.ssh/id
我正在尝试运行一个相对简单的 Ansible 剧本来通过 Vagrant 配置 Ubuntu 虚拟机。大致分为 3 个步骤: 更新并安装必要的软件包 将 rbenv 安装到指定用户的家中 通过rben
我是 ansible(和 docker)的新手。我想在任何暂存/生产服务器上使用我的 ansible playbook 之前对其进行测试。 由于我无法访问空的远程服务器,我认为最简单的测试方法是使用
通过 fork 变量,我可以告诉 ansible 应该并行执行多少台主机。当之前的所有主机完成时,将执行下一个主机。如果主机上的执行时间不同,我必须等待最后一台主机完成。 是否可以告诉 ansible
我是一名优秀的程序员,十分优秀!