{"id":2061,"date":"2023-03-05T18:46:48","date_gmt":"2023-03-05T18:46:48","guid":{"rendered":"https:\/\/linuxdigest.com\/?p=2061"},"modified":"2023-03-05T18:56:28","modified_gmt":"2023-03-05T18:56:28","slug":"ansible-run-one-host-at-a-time","status":"publish","type":"post","link":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/","title":{"rendered":"Run on Only One Host at a Time With Ansible"},"content":{"rendered":"\n<p>Just today, I had to run an Ansible playbook on a large number of hosts. By default, Ansible will run each task on all the hosts affected by the play using 5 forks. It will only move to the next task when all the hosts have completed the running task.<\/p>\n\n\n\n<p>In my case, this was not optimal, since I had to stop an important service on every host in the beginning of the playbook and only start it at the end. That would mean the service would be down on all the hosts while the playbook would be run on a big number of hosts. Which would be a very long time.<\/p>\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Run_the_entire_playbook_on_only_one_host_at_a_time\" title=\"Run the entire playbook on only one host at a time\">Run the entire playbook on only one host at a time<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Run_just_one_task_one_host_at_a_time\" title=\"Run just one task, one host at a time\">Run just one task, one host at a time<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Run_a_playbook_without_forking_from_the_command_line\" title=\"Run a playbook without forking from the command line\">Run a playbook without forking from the command line<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Limit_a_task_to_run_only_on_one_host_with_run_once\" title=\"Limit a task to run only on one host with run_once\">Limit a task to run only on one host with run_once<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Ordering_hosts\" title=\"Ordering hosts\">Ordering hosts<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#The_order_keyword\" title=\"The order keyword\">The order keyword<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#The_strategy_keyword\" title=\"The strategy keyword\">The strategy keyword<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#Thats_it_for_now\" title=\"That&#8217;s it for now\">That&#8217;s it for now<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n\n<p>Of course, I could just run the playbook on one host with the <strong>&#8211;limit<\/strong> argument. Which is the obvious choice when you only want the task to run on one host. But then I would have to either sit there and restart the run for every host or write a script to do it for me. Surely, Ansible can do this more intelligently? Below you can see what I found in my research effort.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Run_the_entire_playbook_on_only_one_host_at_a_time\"><\/span>Run the entire playbook on only one host at a time<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are a bunch of options to control how many hosts the playbook is executed on. The one I decided to use was the <strong>serial<\/strong> keyword at the play level.<\/p>\n\n\n\n<p>The <strong>serial<\/strong> keyword defines how many hosts the playbook is run on at a time. Once the playbook execution is finished, it will be run again on a new batch of hosts.<\/p>\n\n\n\n<p>You can use the <strong>serial<\/strong> keyword with a different batch size than 1. Say you have multiple hosts you want to execute the playbook on. But only two at a time. Then you would set <strong>serial<\/strong> to 2.<\/p>\n\n\n\n<p>Here you can see how you would define a playbook where the playbook will run on just one host at a time.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">---\n- name: Run play on some remote hosts\n  hosts: all\n  serial: 1\n\n  tasks:\n    - name: first task\n      command: echo \"This is the first task\"\n    - name: second task\n      command: echo \"This is the second task\"<\/pre>\n\n\n\n<p>The serial keyword has some other ways to affect play execution, such as defining multiple batch sizes and defining a percentage of hosts to run in the same batch.<\/p>\n\n\n\n<p>You can define an arbitrary percentage to run the play on at a time. Let&#8217;s say you want a play to be executed by 30% of the hosts before moving on to the next host. Then you would add serial: &#8220;30%&#8221; like so:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> ---\n- name: Run play on some remote hosts\n  hosts: all\n  serial: 1<\/pre>\n\n\n\n<p>Don&#8217;t worry. You don&#8217;t have to divide equally. If there are less than 30% of the hosts left. The final pass will run the play on all the remaining hosts.<\/p>\n\n\n\n<p>You can also list multiple batch sizes to run the play on. As an example, if we want to run the task on a single host to see if it is successful before we move on to the following batch. If the task fails we can break the execution and fix the problem.<\/p>\n\n\n\n<p>Then we would create a list of batches where the first batch is set to one.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4-6\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> ---\n- name: Run play on some remote hosts\n  hosts: all  \n  serial:\n    - 1\n    - 10<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Run_just_one_task_one_host_at_a_time\"><\/span>Run just one task, one host at a time<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>How about if you want to do this on a task level?<\/p>\n\n\n\n<p>Then you would use the <strong>throttle<\/strong> keyword. This keyword will instruct Ansible to run just one specific task on one or more hosts at a time. Depending on the value you define.<\/p>\n\n\n\n<p>This way, Ansible executes all other tasks as it would normally do.<\/p>\n\n\n\n<p>Let&#8217;s try the same playbook as we did before. Only this time, we will skip the serial keyword and add the <strong>throttle<\/strong> keyword.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"8\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">---\n- name: Run play on some remote machines\n  hosts: all\n\n  tasks:\n    - name: Task runs on one host at a time\n      command: echo \"This is the first task\"\n      throttle: 1\n    - name: Task is run in parallel\n      command: echo \"This is the second task\"<\/pre>\n\n\n\n<p>If we had five hosts in our inventory and executed this playbook. Ansible would run the first task, one single host at a time. When the last remaining host is done it would run the second one on all hosts in parallel. As is the default behavior.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Run_a_playbook_without_forking_from_the_command_line\"><\/span>Run a playbook without forking from the command line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There is also one more way to limit the number of hosts Ansible tries to run at a time. That is the <strong>forks<\/strong> setting. This controls how many forks ansible will start to run tasks in parallel. Ansible will still run each task on the same number of hosts, but it will either slow down or speed up the process depending on how you set it.<\/p>\n\n\n\n<p>This could be very beneficial if your ansible control node has a lot of processing power available and you want to get through the playbook execution as fast as possible. If your control node doesn&#8217;t have as much processing power or you want to let the playbook run slowly in the background, you can set it to a lower setting.<\/p>\n\n\n\n<p>There are two ways to change this setting. In your ansible.cfg file or as a parameter on the command line.<\/p>\n\n\n\n<p>To change it in your configuration file, all you need to do is add <strong>forks=n<\/strong> to <strong>ansible.cfg <\/strong>like so:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"ini\" data-enlighter-theme=\"\" data-enlighter-highlight=\"2\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[defaults]\nforks = 2<\/pre>\n\n\n\n<p>In the above example, Ansible will spin up 2 forks each time you run a playbook. The default behavior is to use 5 forks. So set the forks variable to a number higher than 5 to speed up and lower if you want to slow down.<\/p>\n\n\n\n<p>This can also be set every time you run a playbook with the Ansible playbook command. For this, you would use the <strong>&#8211;forks<\/strong> or <strong>-f<\/strong> parameters.<\/p>\n\n\n\n<p>This example would limit the number of threads to 1:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ansible-playbook --forks 1 myplaybook.yml<\/pre>\n\n\n\n<p>And if you want to shorten the command, using <strong>-f<\/strong> will do the exact same thing:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ansible-playbook -f 1 myplaybook.yml<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Limit_a_task_to_run_only_on_one_host_with_run_once\"><\/span>Limit a task to run only on one host with run_once<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>I think we have covered how to control parallelism in Ansible quite well. But what if you want a task to run on just the first host and then skip it on all the other hosts in the play completely?<\/p>\n\n\n\n<p>That&#8217;s where the <strong>run_once<\/strong> keyword comes into play. When you add run_once: true to a task, the task will only run on the first host in the batch and skip the remaining hosts.<\/p>\n\n\n\n<p>Have a look at this example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"7\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">- name: Run on all remote machines but not the first task.\n  hosts: webservers\n\n  tasks:\n    - name: This will be run on the first host\n      command: echo \"This is the first task\"\n      run_once: true\n    - name: Second task\n      command: echo \"This is the second one\"<\/pre>\n\n\n\n<p>In this example, Ansible will only attempt the execution of the first task on one host. I will then run the second task on all the hosts in the current batch.<\/p>\n\n\n\n<p>You can even delegate the task to some specific host. It would be beneficial if you had to add DNS records for all the hosts, change load balancer settings, etc.<\/p>\n\n\n\n<p>Just add the <strong>delegate_to<\/strong> keyword to your task, and it will only be run on the delegated host.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"7-8\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">- name: Delegate one task\n  hosts: webservers\n\n  tasks:\n    - name: First task that will only be run on dns.example.com\n      command: echo \"This is the first task\"\n      run_once: true\n      delegate_to: dns.example.com\n    - name: Run on all including the original host\n      command: echo \"This is the second task\"<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Ordering_hosts\"><\/span>Ordering hosts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>I have shown you several keywords to control how much is done in parallel. It could also be helpful to be able to order the hosts in some way.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_order_keyword\"><\/span>The order keyword<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can set the order of your hosts at the playbook level. The default behavior is to run the plays on hosts in the order they appear in your inventory. Simply add the <strong>order<\/strong> keyword with one of these values:<\/p>\n\n\n\n<ul><li><strong>reverse_inventory<\/strong>: The reverse of the order that the inventory is in<\/li><li><strong>sorted<\/strong>: Sort alphabetically<\/li><li><strong>reverse_sorted<\/strong>: Sort alphabetically and reverse the result<\/li><li><strong>shuffle<\/strong>: Shuffle the order on each run<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_strategy_keyword\"><\/span>The strategy keyword<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The default strategy that is used is the linear strategy. You can use a different strategy plugin by using the <strong>strategy<\/strong> keyword in your playbook.<\/p>\n\n\n\n<ul><li><strong>linear<\/strong> (default): Run each task on as many hosts as specified by the forks setting and then move on to the next batch of hosts<\/li><li><strong>free<\/strong>: Same as above but don&#8217;t wait for hosts to finish their task before queuing up the next one.<\/li><li><strong>debug<\/strong>: Same as linear but is controlled by an interactive debug session<\/li><li><strong>host_pinned<\/strong>: Same as linear but never start a task on a host unless other tasks can be completed without waiting for other hosts.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Thats_it_for_now\"><\/span>That&#8217;s it for now<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you got it this far you should know a lot more about controlling executions in Ansible. In my personal experience, these are all necessary skills to know when using Ansible in a large environment.<\/p>\n\n\n\n<p>Most tasks won&#8217;t require you to give this much thought to the execution order and speed. But when it is needed it is usually important.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just today, I had to run an Ansible playbook on a large number of hosts. By&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1923,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[37],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Run on Only One Host at a Time With Ansible - Linux Digest<\/title>\n<meta name=\"description\" content=\"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Run on Only One Host at a Time With Ansible - Linux Digest\" \/>\n<meta property=\"og:description\" content=\"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Digest\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-05T18:46:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-05T18:56:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2020\/11\/Copy-of-Untitled-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"The Linux Digest Guy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"The Linux Digest Guy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\"},\"author\":{\"name\":\"The Linux Digest Guy\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\"},\"headline\":\"Run on Only One Host at a Time With Ansible\",\"datePublished\":\"2023-03-05T18:46:48+00:00\",\"dateModified\":\"2023-03-05T18:56:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\"},\"wordCount\":1350,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"articleSection\":[\"Devops\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\",\"url\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\",\"name\":\"Run on Only One Host at a Time With Ansible - Linux Digest\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/#website\"},\"datePublished\":\"2023-03-05T18:46:48+00:00\",\"dateModified\":\"2023-03-05T18:56:28+00:00\",\"description\":\"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.\",\"breadcrumb\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/linuxdigest.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Run on Only One Host at a Time With Ansible\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/linuxdigest.com\/#website\",\"url\":\"https:\/\/linuxdigest.com\/\",\"name\":\"Linux Digest\",\"description\":\"Linux tutorials for everyone\",\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/linuxdigest.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/linuxdigest.com\/#organization\",\"name\":\"Linux Digest\",\"url\":\"https:\/\/linuxdigest.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"contentUrl\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"width\":1102,\"height\":170,\"caption\":\"Linux Digest\"},\"image\":{\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\",\"name\":\"The Linux Digest Guy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"caption\":\"The Linux Digest Guy\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Run on Only One Host at a Time With Ansible - Linux Digest","description":"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/","og_locale":"en_US","og_type":"article","og_title":"Run on Only One Host at a Time With Ansible - Linux Digest","og_description":"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.","og_url":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/","og_site_name":"Linux Digest","article_published_time":"2023-03-05T18:46:48+00:00","article_modified_time":"2023-03-05T18:56:28+00:00","og_image":[{"width":350,"height":200,"url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2020\/11\/Copy-of-Untitled-2.jpg","type":"image\/jpeg"}],"author":"The Linux Digest Guy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"The Linux Digest Guy","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#article","isPartOf":{"@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/"},"author":{"name":"The Linux Digest Guy","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2"},"headline":"Run on Only One Host at a Time With Ansible","datePublished":"2023-03-05T18:46:48+00:00","dateModified":"2023-03-05T18:56:28+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/"},"wordCount":1350,"commentCount":0,"publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"articleSection":["Devops"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/","url":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/","name":"Run on Only One Host at a Time With Ansible - Linux Digest","isPartOf":{"@id":"https:\/\/linuxdigest.com\/#website"},"datePublished":"2023-03-05T18:46:48+00:00","dateModified":"2023-03-05T18:56:28+00:00","description":"Ansible will run plays and tasks on multiple hosts in parallel. You can change this behaviour and run a task or play on one host at a time.","breadcrumb":{"@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/linuxdigest.com\/howto\/ansible-run-one-host-at-a-time\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxdigest.com\/"},{"@type":"ListItem","position":2,"name":"Run on Only One Host at a Time With Ansible"}]},{"@type":"WebSite","@id":"https:\/\/linuxdigest.com\/#website","url":"https:\/\/linuxdigest.com\/","name":"Linux Digest","description":"Linux tutorials for everyone","publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxdigest.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxdigest.com\/#organization","name":"Linux Digest","url":"https:\/\/linuxdigest.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","contentUrl":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","width":1102,"height":170,"caption":"Linux Digest"},"image":{"@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2","name":"The Linux Digest Guy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","caption":"The Linux Digest Guy"}}]}},"_links":{"self":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2061"}],"collection":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/comments?post=2061"}],"version-history":[{"count":5,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2061\/revisions"}],"predecessor-version":[{"id":2068,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2061\/revisions\/2068"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media\/1923"}],"wp:attachment":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media?parent=2061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/categories?post=2061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/tags?post=2061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}