Skip to content

Commit

Permalink
[AUTO] Static site update for 4938286
Browse files Browse the repository at this point in the history
  • Loading branch information
gfaivre committed Jan 29, 2024
1 parent 31787fa commit 0effd83
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
20 changes: 14 additions & 6 deletions blog/cours/ansible/ansible-les-playbooks/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"https://rix-fr.github.io/rix/blog/cours/ansible/content/images/blog/thumbnails/ansible-playbooks.jpg"
],
"datePublished": "5 décembre 2023",
"dateModified": "22 janvier 2024",
"dateModified": "29 janvier 2024",
"author": [
{
"@type": "Person",
Expand Down Expand Up @@ -286,7 +286,7 @@ <h2 class="h2--large">Ansible - Les playbooks</h2>
</div>
<div class="article-info__date">
<span>Publication <strong>5 décembre 2023</strong></span>
<span>Modification <strong>22 janvier 2024</strong></span>
<span>Modification <strong>29 janvier 2024</strong></span>
</div>
</div>
</div>
Expand Down Expand Up @@ -541,7 +541,7 @@ <h4 id="la-section-pre-tasks" class="anchor-title"><a href="#la-section-pre-task
<li>Soit créer un nouveau playbook dédié aux instances de bases de données <code class="code-inline" id="5e770988217638696ce7e93a56c3da3d">dbservers.yml</code>.</li>
</ul>
<p>Nous nous orienterons pour l'exemple, sur cette seconde option, nous créerons donc un fichier <code class="code-inline" id="5e770988217638696ce7e93a56c3da3d">dbservers.yml</code> à la racine de notre répertoire de travail dont le contenu ressemblera beaucoup à celui de <code class="code-inline" id="35e10f4319de8bbbbd2033b3448a5e5d">webservers.yml</code>.</p>
<pre class="code-multiline language-yaml"><code class="language-yaml" id="df38da0b2044de0ca8a7d75e8b86d07b"><span class="token punctuation">-</span> <span class="token key atrule">hosts</span><span class="token punctuation">:</span> dbservers
<pre class="code-multiline language-yaml"><code class="language-yaml" id="a0409a75a354f079b77aeb45a0f55314"><span class="token punctuation">-</span> <span class="token key atrule">hosts</span><span class="token punctuation">:</span> dbservers

<span class="token key atrule">pre_tasks</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Updating APT cache index
Expand All @@ -553,9 +553,7 @@ <h4 id="la-section-pre-tasks" class="anchor-title"><a href="#la-section-pre-task
<span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> Install MariaDB server
<span class="token key atrule">ansible.builtin.apt</span><span class="token punctuation">:</span>
<span class="token key atrule">name</span><span class="token punctuation">:</span> mariadb<span class="token punctuation">-</span>server
<span class="token key atrule">state</span><span class="token punctuation">:</span> present
<span class="token key atrule">notify</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> restart_mariadb</code></pre>
<span class="token key atrule">state</span><span class="token punctuation">:</span> present</code></pre>
<p>Notre nouveau playbook est bien evidemment « jouable » à l'aide de la commande <code class="code-inline" id="8ee9161eaa245fd21d6887f8a5e0cd4b">ansible-playbook dbservers.yml -i inventories</code>.</p>
<h4 id="les-handlers" class="anchor-title"><a href="#les-handlers">Les handlers</a></h4>
<p>Bien, reprenons notre exemple d'installation d'Nginx, nous avons un paquet « tout neuf » auquel nous n'avons apporté aucune configuration pour l'instant.
Expand Down Expand Up @@ -731,6 +729,16 @@ <h4 id="les-instructions-import-et-export" class="anchor-title"><a href="#les-in
<pre class="code-multiline language-yaml"><code class="language-yaml" id="95e8e7ff0d30ec6b7d97b785902b9f74"><span class="token punctuation">-</span> <span class="token key atrule">ansible.builtin.import_playbook</span><span class="token punctuation">:</span> webservers.yml
<span class="token punctuation">-</span> <span class="token key atrule">ansible.builtin.import_playbook</span><span class="token punctuation">:</span> dbservers.yml</code></pre>
<p>Nous pouvons à présent jouer l'ensemble avec la commande: <code class="code-inline" id="8c7354e1cff57ed36e4431314a54e660">ansible-playbook main.yml -i inventories</code> !</p>
<p>Tout semble fonctionner ! Mais est-ce vraiment le cas ?
Modifiez à nouveau le fichier de configuration <code class="code-inline" id="617f940792257db3b58a57be6b4a6c50">status.conf</code> destiné à Nginx et relancer le provisionning.</p>
<p>Vous devriez vous retrouver avec l'erreur <code class="code-inline" id="f40ea55e1ea4604069bc09b42697416a">ERROR! The requested handler 'restart_nginx' was not found in either the main handlers list nor in the listening handlers list</code> ! </p>
<p>En effet nous avons utilisé une directive de type <code class="code-inline" id="d436eb0fd9de10b54a828ce6435f7e81">include</code> pour inclure notre fichier de handlers, or nous avons vu que ces instructions ne sont pas « pré-traitées ». Ansible lorsqu'il parcours notre playbook rencontre donc l'instruction:</p>
<pre class="code-multiline language-yaml"><code class="language-yaml" id="32921237cf69dc04426071b8c0b9b9a4"><span class="token key atrule">notify</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> restart_nginx</code></pre>
<p>AVANT que notre fichier <code class="code-inline" id="7f3b19104652c4e477b43b3f04ce0ac2">handlers.yml</code> et donc qu'Ansible ait connaissance de l'existance de ce handler !</p>
<p>Pour corriger ce comportement il faudra donc dans notre cas utiliser la directive:</p>
<pre class="code-multiline language-yaml"><code class="language-yaml" id="a529dd7a521de3e9c5d35a954983c539"><span class="token key atrule">handlers</span><span class="token punctuation">:</span>
<span class="token punctuation">-</span> <span class="token key atrule">ansible.builtin.inport_tasks</span><span class="token punctuation">:</span> handlers.yml</code></pre>
<h3 id="taguer-ses-taches" class="anchor-title"><a href="#taguer-ses-taches">Taguer ses tâches</a></h3>
<p>Nous venons de voir la possibilité de « diviser pour réorganiser » nos tâches, mais il existe également la possibilité de « taguer » nos tâches de manière à les déclencher de manière <strong>ciblée</strong>, ouvrant également la possibilité de les exécuter de façons transverses si celles-ci appartiennent à plusieurs playbooks différents. </p>
<p>Nous verrons qu'ils sont <strong>très utiles voir indispensables</strong> dès lorsque nous aurons abordé la notion de <strong>roles</strong>.</p>
Expand Down
4 changes: 2 additions & 2 deletions blog/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>Découvrez nos articles techniques (ou non), rédigés par les membres de l'équipe Rix !</description>
<copyright>Rix - L’utilisation des flux RSS de rix.fr est réservée à un usage strictement personnel, non professionnel et non collectif. Toute autre exploitation doit faire l’objet d’une autorisation et donner lieu au versement d’une rémunération. Contact : [email protected]</copyright>
<link>https://rix-fr.github.io/rix/blog</link>
<pubDate>Wed, 24 Jan 2024 11:19:39 +0000</pubDate>
<pubDate>Mon, 29 Jan 2024 13:15:20 +0000</pubDate>
<language>fr</language>
<image>
<url>https://rix-fr.github.io/rix/apple-touch-icon.png</url>
Expand All @@ -15,7 +15,7 @@
<atom:link href="https://rix-fr.github.io/rix/blog/rss.xml" rel="self" type="application/rss+xml"/>
<item>
<title>Ansible - Les playbooks</title>
<pubDate>Mon, 22 Jan 2024 00:00:00 +0000</pubDate>
<pubDate>Mon, 29 Jan 2024 00:00:00 +0000</pubDate>
<description>
<![CDATA[ Découverte des playbooks, élément essentiel d&#039;Ansible qui va nous permettre d&#039;organiser et structurer nos tâches ! ]]>
</description>
Expand Down
16 changes: 8 additions & 8 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://rix-fr.github.io/rix/blog</loc>
<lastmod>2024-01-22T00:00:00+00:00</lastmod> <priority>0</priority> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T00:00:00+00:00</lastmod> <priority>0</priority> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/etudes-de-cas</loc>
<lastmod>2022-09-12T00:00:00+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/</loc>
<lastmod>2024-01-24T11:19:52+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/a-propos</loc>
<lastmod>2024-01-24T11:19:52+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/services</loc>
<lastmod>2024-01-24T11:19:54+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/contact</loc>
<lastmod>2024-01-24T11:19:52+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/legal</loc>
<lastmod>2024-01-24T11:19:52+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/confidentialite</loc>
<lastmod>2024-01-24T11:19:52+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T13:15:21+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/blog/cours/ansible/ansible-les-playbooks</loc>
<lastmod>2024-01-22T00:00:00+00:00</lastmod> <changefreq>monthly</changefreq>
<lastmod>2024-01-29T00:00:00+00:00</lastmod> <changefreq>monthly</changefreq>
</url>
<url>
<loc>https://rix-fr.github.io/rix/blog/cours/ansible/ansible-les-inventaires-statiques</loc>
Expand Down

0 comments on commit 0effd83

Please sign in to comment.