简体   繁体   English

Ansible:为每个服务器使用单独的参数运行任务

[英]Ansible: run task with individual parameters for each server

need to run task on several servers: it would be the same pipeline, but different data on eatch server. 需要在多台服务器上运行任务:这将是相同的管道,但是在Eatch服务器上的数据不同。

So, i've list of files. 所以,我有文件列表。 It must be sliced to server-number parts, each sublist pass to individual servers copy of task, than run independantly. 必须将其切成服务器编号部分,每个子列表传递给各个服务器的任务副本,然后才能独立运行。

I don't know how to: 我不知道该怎么做:

  1. separate input list to parts 将输入清单分开
  2. pass slice in server-instance task 在服务器实例任务中传递切片
  3. organize task - it consist of couple of steps (copy to server /tmp folder, copy from server to local, remove /tmp to release disk-space). 组织任务-它包括几个步骤(复制到服务器/ tmp文件夹,从服务器复制到本地,删除/ tmp释放磁盘空间)。 It must be another playbook, with included to my playbook? 它一定是另一本剧本,并且包含在我的剧本中吗? Don't know how to set couple of subtasks in one loop. 不知道如何在一个循环中设置几个子任务。

All exapmles and askes talk about runing differnt task in parallel. 所有实例和问询者都谈到并行运行不同的任务。 But i have the same task, but parametrized. 但是我有相同的任务,但是参数化了。 If there're no list of files as parameter, it runs trivially: just set hosts, and set task. 如果没有文件列表作为参数,它将简单地运行:只需设置主机,然后设置任务即可。

An option to 一个选项

"run task on several servers ..., but different data on each server" “在多个服务器上运行任务...,但是每个服务器上的数据不同”

would be to include files with different data for each server. 将为每个服务器包括具有不同数据的文件。

- include_vars: "{{ ansible_hostname }}.yaml"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ansible shell 无法运行 shell 脚本任务 - Ansible shell failing to run shell script task Ansible - 如何使用参数运行 Java jar? - Ansible - how to run Java jar with parameters? Ansible:将一个唯一的文件复制到组中的每个服务器 - Ansible: copying one unique file to each server in a group 在rake任务上运行bash命令之前运行服务器 - Run server before to run bash command on rake task Ansible:任务中的Access Shell Var - Ansible: Access Shell Var in Task 按区域运行 Ansible 剧本 - Run Ansible Playbooks by region 如何编写脚本以在后台运行多个进程并在每个单独的命令完成后运行其他命令? - How do I write a script to run multiple processes in the background and have additional commands run once each individual command completes? 如何在 ansible 剧本中将目标服务器将运行任务的主机名字符串定义为变量? - How to define as variables the strings of hostname of target-server-which-will-run-the-tasks in ansible playbook? 在 ansible 中以 root 身份登录后执行任务 - Executing task after being logged as root in ansible sbatch --array 命令中的值与作业任务 ID 不同,它们每个都在不同的作业中运行 - Values in a sbatch --array command different from the job task IDs, each of them run in a different job
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM