{"id":134,"date":"2025-07-07T11:29:05","date_gmt":"2025-07-07T09:29:05","guid":{"rendered":"https:\/\/blog.cp2i.com\/?p=134"},"modified":"2025-07-07T11:29:05","modified_gmt":"2025-07-07T09:29:05","slug":"attendre-la-fin-dun-deploiement-k8s-avec-ansible","status":"publish","type":"post","link":"https:\/\/blog.cp2i.com\/index.php\/2025\/07\/07\/attendre-la-fin-dun-deploiement-k8s-avec-ansible\/","title":{"rendered":"Attendre la fin d&rsquo;un deploiement K8s avec Ansible"},"content":{"rendered":"\n<p>Pour attendre la fin d&rsquo;un d\u00e9ploiement Kubernetes, on pourrait \u00eatre tent\u00e9 d&rsquo;utiliser les options \u00ab\u00a0wait\u00a0\u00bb et \u00ab\u00a0wait_conidition\u00a0\u00bb. Cependant, ces options posent probl\u00e8me lorsque le playbook de d\u00e9ploiement est lanc\u00e9 plusieurs fois.<\/p>\n\n\n\n<p>Afin de r\u00e9gler ce soucis, il suffit de rajouter une \u00e9tape dans notre t\u00e2che comme suit (exemple de longhorn):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">- name: Wait until longhorn is up\n  kubernetes.core.k8s_info:\n    kubeconfig: <span class=\"hljs-string\">\"{{ kubeconfig_file }}\"<\/span>\n    <span class=\"hljs-attr\">api_version<\/span>: v1\n    <span class=\"hljs-attr\">kind<\/span>: Pod\n    <span class=\"hljs-attr\">namespace<\/span>: <span class=\"hljs-string\">\"{{ longhorn_namespace }}\"<\/span>\n  <span class=\"hljs-attr\">register<\/span>: pod_list\n  <span class=\"hljs-attr\">until<\/span>: pod_list|json_query(<span class=\"hljs-string\">'resources&#91;*].status.phase'<\/span>)|unique == &#91;<span class=\"hljs-string\">\"Running\"<\/span>]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Langage du code\u00a0:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Ainsi, tant que les pods du namespace ne sont pas tous en statut Running, la t\u00e2che ne poursuivra pas son cours.<\/p>\n\n\n\n<p>Jesp\u00e8re que cela vous aura \u00e9t\u00e9 utile !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pour attendre la fin d&rsquo;un d\u00e9ploiement Kubernetes, on pourrait \u00eatre tent\u00e9 d&rsquo;utiliser les options \u00ab\u00a0wait\u00a0\u00bb et \u00ab\u00a0wait_conidition\u00a0\u00bb. Cependant, ces options posent probl\u00e8me lorsque le playbook de d\u00e9ploiement est lanc\u00e9 plusieurs fois. Afin de r\u00e9gler ce soucis, il suffit de rajouter une \u00e9tape dans notre t\u00e2che comme suit (exemple de longhorn): Ainsi, tant que les pods [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_regular_price":[],"currency_symbol":[],"footnotes":""},"categories":[18,20,19],"tags":[],"class_list":["post-134","post","type-post","status-publish","format-standard","hentry","category-ansible","category-automatisation","category-kubernetes"],"post_slider_layout_featured_media_urls":{"thumbnail":"","post_slider_layout_landscape_large":"","post_slider_layout_portrait_large":"","post_slider_layout_square_large":"","post_slider_layout_landscape":"","post_slider_layout_portrait":"","post_slider_layout_square":"","full":""},"_links":{"self":[{"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/posts\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/comments?post=134"}],"version-history":[{"count":1,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/posts\/134\/revisions"}],"predecessor-version":[{"id":135,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/posts\/134\/revisions\/135"}],"wp:attachment":[{"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/media?parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/categories?post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cp2i.com\/index.php\/wp-json\/wp\/v2\/tags?post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}