<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Live from my brain with some lag</title>
    <description>Pense-bête &amp; Todos Ruby, Python, devops, Linux, Raspberry π, ...
</description>
    <link>https://blog.ledez.net/</link>
    <atom:link href="https://blog.ledez.net/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 25 Mar 2022 02:24:26 -0500</pubDate>
    <lastBuildDate>Fri, 25 Mar 2022 02:24:26 -0500</lastBuildDate>
    <generator>Jekyll v4.2.0</generator>
    
      <item>
        <title>OVH OpenStack Stein port_security avec Terraform</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2022/03/TerraformStein.png&quot; alt=&quot;Terraform avec OpenStack Stein&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.ledez.net/computing/ovh-openstack-stein-port-security-with-terraform-en/&quot;&gt;In English&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Si comme moi tu t’es réveillé avec ton plan Terraform qui ne passe plus après
&lt;a href=&quot;https://public-cloud.status-ovhcloud.com/incidents/6fh4b3x6plh2&quot;&gt;une mise à jour OVH de l’OpenStack&lt;/a&gt;
en version &lt;a href=&quot;https://www.openstack.org/software/stein/&quot;&gt;Stein&lt;/a&gt;.
Ce qui va suivre devrait t’intéresser.&lt;/p&gt;

&lt;p&gt;J’avais cette erreur-là :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot; data-lang=&quot;plaintext&quot;&gt;Exceeded maximum number of retries. Exceeded max scheduling attempts 6 for
instance XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. Last exception: Network requires
port_security_enabled and subnet associated in order to apply security groups.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;!--more--&gt;

&lt;p&gt;Concrètement, tu as un plan Terraform comme ceci :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_compute_instance_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;image_name&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ubuntu&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;flavor_name&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;d1-2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;security_groups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Ext-Net&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vrack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Au moment du &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform apply&lt;/code&gt;, tu as l’erreur ci-dessus. Et même pire que ça,
Terraform tourne en boucle.&lt;/p&gt;

&lt;p&gt;C’est le passage en &lt;a href=&quot;https://www.openstack.org/software/stein/&quot;&gt;Stein&lt;/a&gt; qui est en cause.&lt;/p&gt;

&lt;p&gt;Avant, tu avais ta VM. Tu lui spécifiais :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;La liste des réseaux auxquels se rattacher&lt;/li&gt;
  &lt;li&gt;La liste des security groups des lesquels mettre la &lt;em&gt;VM&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Openstack créait automatiquement les ports (interfaces réseau virtuelles) et
Terraform appliquait les security groups à la machine, donc à l’ensemble des
ports (publics comme vrack).&lt;/p&gt;

&lt;p&gt;Maintenant, il ne faut appliquer les security groups que sur les ports externes
et non au niveau de l’ensemble des ports.&lt;/p&gt;

&lt;p&gt;La bonne nouvelle, c’est qu’à terme on va pouvoir enfin mettre des security groups
aux interfaces assignées aux vracks sur toutes les régions, comme c’est déjà
possible sur GRA9 !!!&lt;/p&gt;

&lt;p&gt;Bon, comment tu fais marcher tout ça ?!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Pour&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;avoir&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;les&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;UUID&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;des&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;réseaux&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;plus&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tard&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;net_public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Ext-Net&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;net_vrack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vrack&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Pour&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;avoir&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;les&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;UUID&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;des&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;groups&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;plus&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;tard&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Maintenant&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;les&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ports&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Le&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;avec&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;les&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;groups&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1-public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;network_id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net_public&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;security_group_ids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;admin_state_up&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Le&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;privé&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sans&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;group&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;priv&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1-priv&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;network_id&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net_vrack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;admin_state_up&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Et&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;enfin&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;la&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;VM&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_compute_instance_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;image_name&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ubuntu&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;flavor_name&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;d1-2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;priv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà ! :)&lt;/p&gt;
</description>
        <pubDate>Thu, 24 Mar 2022 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/informatique/ovh-openstack-stein-port-security-avec-terraform-fr/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/ovh-openstack-stein-port-security-avec-terraform-fr/</guid>
        
        <category>Informatique</category>
        
        <category>terraform</category>
        
        <category>ovhpubliccloud</category>
        
        
        <category>Informatique</category>
        
      </item>
    
      <item>
        <title>OVH OpenStack Stein port_security with Terraform</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2022/03/TerraformStein.png&quot; alt=&quot;Terraform avec OpenStack Stein&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.ledez.net/informatique/ovh-openstack-stein-port-security-avec-terraform-fr/&quot;&gt;En français&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If like me you woke up with your Terraform plan no longer passing after
&lt;a href=&quot;https://public-cloud.status-ovhcloud.com/incidents/6fh4b3x6plh2&quot;&gt;an OVH update of the OpenStack&lt;/a&gt;
to &lt;a href=&quot;https://www.openstack.org/software/stein/&quot;&gt;Stein&lt;/a&gt;.
What follows should be of interest to you.&lt;/p&gt;

&lt;p&gt;I had this error:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot; data-lang=&quot;plaintext&quot;&gt;Exceeded maximum number of retries. Exceeded max scheduling attempts 6 for
instance XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. Last exception: Network requires
port_security_enabled and subnet associated in order to apply security groups.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;!--more--&gt;

&lt;p&gt;Concretely, you have a Terraform plan like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_compute_instance_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;image_name&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ubuntu&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;flavor_name&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;d1-2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;security_groups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Ext-Net&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vrack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;At the time of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform apply&lt;/code&gt;, you have the above error. And even worse than that,
Terraform is running in a loop.&lt;/p&gt;

&lt;p&gt;It is the change to &lt;a href=&quot;https://www.openstack.org/software/stein/&quot;&gt;Stein&lt;/a&gt; which is in cause.&lt;/p&gt;

&lt;p&gt;Before, you had your VM. You would specify to it:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The list of networks to attach to&lt;/li&gt;
  &lt;li&gt;The list of security groups to put the &lt;em&gt;VM&lt;/em&gt; in&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Openstack automatically created the ports (virtual network interfaces) and
Terraform applied the security groups to the machine, i.e. to all the ports (public as well as
ports (both public and vrack).&lt;/p&gt;

&lt;p&gt;Now, you have to apply security groups only on external ports
and not on all ports.&lt;/p&gt;

&lt;p&gt;The good news is that in the future we will finally be able to put security groups
to the interfaces assigned to the vracks on all the regions, as it is already
possible on GRA9 !!!&lt;/p&gt;

&lt;p&gt;Well, how do you make it all work?!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tf&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;have&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;UUID&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;networks&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;later&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;net_public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Ext-Net&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;net_vrack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vrack&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;To&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;have&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;UUID&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;of&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;groups&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;later&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Now&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ports&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;groups&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1-public&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;network_id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net_public&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;security_group_ids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_secgroup_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;admin_state_up&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;without&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;security&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;group&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;priv&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1-priv&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;network_id&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;openstack_networking_network_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net_vrack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;admin_state_up&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;And&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;finally&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;VM&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;openstack_compute_instance_v2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;vm1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;image_name&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;ubuntu&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;flavor_name&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;d1-2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;network&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;openstack_networking_port_v2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;priv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And voila! :)&lt;/p&gt;
</description>
        <pubDate>Wed, 23 Mar 2022 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/computing/ovh-openstack-stein-port-security-with-terraform-en/</link>
        <guid isPermaLink="true">https://blog.ledez.net/computing/ovh-openstack-stein-port-security-with-terraform-en/</guid>
        
        <category>computing</category>
        
        <category>terraform</category>
        
        <category>ovhpubliccloud</category>
        
        
        <category>Computing</category>
        
      </item>
    
      <item>
        <title>Sauvegardes, analyse de risque, PRA et PCA</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2021/03/backup-burning.jpg&quot; alt=&quot;Sauvegardes, analyse de risque&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Bon, je ne vais pas revenir sur l’incident d’OVH :&lt;/p&gt;
&lt;div class=&quot;jekyll-twitter-plugin&quot;&gt;&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;fr&quot; dir=&quot;ltr&quot;&gt;Statut sur l’incident sur notre site de Strasbourg : &lt;a href=&quot;https://t.co/zkwslZX34e&quot;&gt;https://t.co/zkwslZX34e&lt;/a&gt;&lt;/p&gt;&amp;mdash; OVHcloud Support FR (@ovh_support_fr) &lt;a href=&quot;https://twitter.com/ovh_support_fr/status/1369602998633172994?ref_src=twsrc%5Etfw&quot;&gt;March 10, 2021&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;/div&gt;

&lt;p&gt;Mais ça fait un moment qu’un petit article sur l’analyse de risque me trotte dans la tête. Et visiblement, c’est le bon timing pour éviter d’être à nouveau dans la panade.&lt;/p&gt;

&lt;p&gt;Disclamer: Les cordonniers sont les plus mal chaussés. &lt;a href=&quot;/informatique/comment-récupérer-un-rm-rf-var-lib-mysql/&quot;&gt;Et personne n’est à l’abri d’une erreur&lt;/a&gt;
Et je ne suis pas un “spécialiste” en sécurité, dans le sens ou ce n’est pas mon activité principale (audit, flux, etc.). Mais j’ai fait une spécialisation dans mes études ce qui m’a donné des bases. Et j’ai toujours appliqué ces préceptes dans ma vie pro/perso.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Bon, alors déjà c’est quoi un risque ? Sur Wikipedia, on peut lire deux pages :
&lt;a href=&quot;https://fr.wikipedia.org/wiki/Risque#Dans_l'informatique&quot;&gt;Risque&lt;/a&gt; et &lt;a href=&quot;https://fr.wikipedia.org/wiki/S%C3%A9curit%C3%A9_des_syst%C3%A8mes_d%27information&quot;&gt;Sécurité des systèmes d’information&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ce que l’on peut retenir, c’est la définition :
“Le risque est la possibilité de survenue d’un événement indésirable, la probabilité d’occurrence d’un péril probable ou d’un aléa”&lt;/p&gt;

&lt;p&gt;Et une formule mathématique que je vais simplifier :
r = p⋅C&lt;/p&gt;

&lt;p&gt;En bon français, le risque est égal à la probabilité multipliée par la conséquence (financière par exemple).&lt;/p&gt;

&lt;p&gt;Ensuite, une fois que l’on a évalué ce risque, on va choisir de le prendre en compte ou pas. Et donc le traiter si besoin.&lt;/p&gt;

&lt;p&gt;Bon, c’est bien gentil tout ça, mais j’en fais quoi ? On va prendre quelques cas simples que j’ai rencontrés dans ma vie de sysadmin (le vieux nom de devops/sre/…).&lt;/p&gt;

&lt;h1 id=&quot;cas-numéro-1---un-serveur-dédié-chez-ovh&quot;&gt;Cas numéro 1 - un serveur dédié chez OVH&lt;/h1&gt;

&lt;h2 id=&quot;lanalyse-de-risque&quot;&gt;L’analyse de risque&lt;/h2&gt;

&lt;p&gt;Légende :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Mon app est plus ou moins injoignable -&amp;gt; +/-&lt;/li&gt;
  &lt;li&gt;Mon app est totalement injoignable -&amp;gt; ☠️&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Risques&lt;/th&gt;
      &lt;th&gt;probabilité&lt;/th&gt;
      &lt;th&gt;conséquence&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Je fais un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm -rf&lt;/code&gt; dans mes fichiers&lt;/td&gt;
      &lt;td&gt;Haute&lt;/td&gt;
      &lt;td&gt;+/-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Je fais un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE from ITEMS&lt;/code&gt; dans ma base de données&lt;/td&gt;
      &lt;td&gt;Haute&lt;/td&gt;
      &lt;td&gt;+/-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Je me fais pirater (remplacement des fichiers)&lt;/td&gt;
      &lt;td&gt;Moyenne&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Un composant de ma machine tombe en panne&lt;/td&gt;
      &lt;td&gt;Moyenne&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Le disque dur tombe en panne&lt;/td&gt;
      &lt;td&gt;Moyenne&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ma machine ne redémarre pas&lt;/td&gt;
      &lt;td&gt;Moyenne&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;La machine brûle / l’hébergeur devient injoignable&lt;/td&gt;
      &lt;td&gt;Faible&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Le continent où est hébergé le serveur disparaît&lt;/td&gt;
      &lt;td&gt;Très faible&lt;/td&gt;
      &lt;td&gt;☠️&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Bon, on peut aussi chercher à estimer les coûts, mais globalement on ne veut ni perdre de donnée ni que l’application soit indisponible.&lt;/p&gt;

&lt;h2 id=&quot;les-contre-mesures&quot;&gt;Les contre-mesures&lt;/h2&gt;

&lt;h3 id=&quot;je-fais-un-rm--rf-dans-mes-fichiers&quot;&gt;Je fais un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm -rf&lt;/code&gt; dans mes fichiers&lt;/h3&gt;

&lt;p&gt;Là, c’est le problème à la fois le plus simple et le plus compliqué dont se protéger. Simple parce qu’un bête &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt; peut suffire à réduire le risque. Et compliqué parce que l’on peut vouloir gérer un “historique”, mais aussi s’il y a trop de fichiers/volumétrie.&lt;/p&gt;

&lt;p&gt;Bon, déjà pour gagner du temps pour plus tard, si vous en avez la possibilité, passez directement sur de l’object-storage. Vous allez anticiper pas mal de problèmes pour le futur :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Passer sur plusieurs machines&lt;/li&gt;
  &lt;li&gt;Passer sur des vm “cloud” dont le disque est “volatile”&lt;/li&gt;
  &lt;li&gt;Plusieurs To de fichiers à sauvegarder&lt;/li&gt;
  &lt;li&gt;Plusieurs millions de fichiers à sauvegarder&lt;/li&gt;
  &lt;li&gt;Temps de restauration quand on a plusieurs To&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sinon, ce que je mets souvent en place, c’est :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;rsync sur un serveur de sauvegarde distant (on va y revenir plus tard)&lt;/li&gt;
  &lt;li&gt;des snapshoots sur mon serveur de sauvegarde (j’utilise ZFS maintenant)&lt;/li&gt;
  &lt;li&gt;des snapshoots sur x jours / x semaines / x mois&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Si des fichiers sont supprimés, je fais un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt; dans l’autre sens. À partir d’un snapshoot au besoin.&lt;/p&gt;

&lt;h3 id=&quot;je-fais-un-delete-from-items-dans-ma-base-de-données&quot;&gt;Je fais un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DELETE from ITEMS&lt;/code&gt; dans ma base de données&lt;/h3&gt;

&lt;p&gt;Dans ce cas, je fais tous les jours des sauvegardes locales soit :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;mysqldump/pg_dump&lt;/li&gt;
  &lt;li&gt;quand la base est trop grosse à exporter, backup à chaud/froid style percona backup. Une complète par semaine, puis une incrémentale par jour&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ensuite, tout ça est copié via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt; sur le serveur de backup + un snapshoot.&lt;/p&gt;

&lt;p&gt;Si j’ai besoin de restaurer, j’importe le fichier qui est local, ou je copie du serveur distant. Si c’est un peu plus “chigurgical”, le développeur a accès à une base sur laquelle il peut extraire les données dont il a besoin.&lt;/p&gt;

&lt;h3 id=&quot;je-me-fais-pirater-remplacement-des-fichiers&quot;&gt;Je me fais pirater (remplacement des fichiers)&lt;/h3&gt;

&lt;p&gt;Vous savez, vous vous connectez sur votre site, et vous avez une revendication politique ; un truc du style hacktiviste.&lt;/p&gt;

&lt;p&gt;Là, c’est très simple, on restaure les fichiers. Ensuite on cherche d’où vient la faille pour la corriger. Ou l’inverse si on a le temps.&lt;/p&gt;

&lt;p&gt;Pensez à regarder si personne n’est connecté, sauvegardez/regardez les logs, etc. Dans l’idéal, une fois le problème corrigé, réinstallez complètement l’OS de zéro pour écarter tout risque de compromission résiduelle.&lt;/p&gt;

&lt;h3 id=&quot;un-composant-de-la-machine-tombe-en-panne&quot;&gt;Un composant de la machine tombe en panne&lt;/h3&gt;

&lt;p&gt;Là aussi c’est très simple. Ça arrive que la carte mère crame, le CPU, la RAM, etc. Le serveur ne répond plus ou perd les pédales. Une fois, j’ai eu un load average énorme au moindre curl. C’était la carte mère qui avait pris un jeton… Nous y avions passé la semaine à essayer de comprendre la source du problème…&lt;/p&gt;

&lt;p&gt;Bref un ticket à OVH, on éteint le serveur, on change la pièce, et c’est reparti pour un tour :)&lt;/p&gt;

&lt;p&gt;Bon, c’est clair que pendant ce temps là, l’application est indisponible. Mais tout le monde n’est pas prêt à payer pour du HA.&lt;/p&gt;

&lt;p&gt;Et franchement en 15 ans d’hébergement, je n’ai pas eu tant que ça de problèmes…&lt;/p&gt;

&lt;h3 id=&quot;le-disque-dur-tombe-en-panne&quot;&gt;Le disque dur tombe en panne&lt;/h3&gt;

&lt;p&gt;Encore un problème simple à résoudre. On prend du RAID, on configure ça en RAID 1, 5, 6, JBOD,… tout ce que vous voulez. Mais JAMAIS du 0 sauf si vous voulez tout perdre :p&lt;/p&gt;

&lt;p&gt;Un disque crame =&amp;gt; ticket à OVH pour le changer.&lt;/p&gt;

&lt;p&gt;Bien sûr, pensez à monitorer l’état du RAID. Ce serait con que le deuxième disque lâche avant le remplacement du premier. Oui, j’ai déjà vu ça…&lt;/p&gt;

&lt;h3 id=&quot;ma-machine-ne-redémarre-pas&quot;&gt;Ma machine ne redémarre pas&lt;/h3&gt;

&lt;p&gt;Alors là, c’est le truc très con. Upgrade du noyau, reboot, et on attend……&lt;/p&gt;

&lt;p&gt;Donc, prenez des serveurs avec un KVM (console Keyboard Video Mouse - pas d’intérêt d’avoir la souris pour nous, mais c’est le nom). Et connectez-vous AVANT de rebooter. Et pas juste une connexion au KVM, connectez-vous avec le compte login/pass. Un autre conseil au passage, désactivez la connexion SSH du root. Mais autorisez la connexion en console. Vous me remercierez en cas de galère. Et pensez au mapping du clavier que vous allez utiliser. Je suis passé en full QWERTY depuis 10 ans, ça m’évite pas mal de problèmes de ce côté-là. Et dans vos choix de pass, pensez à ceux qui ont de l’AZERTY/BEPO/…. Ils pourraient pleurer en tapant &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iWzyodO[OZ+CS}g|Y',]|Z2'b&amp;lt;(7/2Ez3kn&lt;/code&gt; :p Et vous aussi, donc privilégiez un truc du type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lakeside-emporium-indulge-ARGOT&lt;/code&gt;, ce sera plus simple à taper dans l’urgence.&lt;/p&gt;

&lt;h3 id=&quot;la-machine-brûle--lhébergeur-devient-injoignable&quot;&gt;La machine brûle / l’hébergeur devient injoignable&lt;/h3&gt;

&lt;p&gt;Bon, clairement un serveur qui brûle c’est rare. Un DC entier, c’est encore plus rare. Mais on a vu que c’était possible. Et quand j’expliquais ça il y a quelques années, les gens/collègues me regardaient en rigolant en me traitant de parano :D&lt;/p&gt;

&lt;p&gt;Encore une fois, la probabilité que ça arrive est très faible. Mais le jour où ça arrive, vous n’avez plus rien. Donc pour se préparer à ça, il faut pouvoir :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Réinstaller l’OS&lt;/li&gt;
  &lt;li&gt;Réinstaller les applicatifs&lt;/li&gt;
  &lt;li&gt;Réinstaller les données&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et comme votre serveur n’est plus là, aucune chance de savoir comment c’était configuré avant…&lt;/p&gt;

&lt;p&gt;Donc :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Gestionnaire de configuration =&amp;gt; Saltstack/Ansible/Chef/Script shell/au pire de la doc&lt;/li&gt;
  &lt;li&gt;Passez régulièrement votre gestionnaire de configuration&lt;/li&gt;
  &lt;li&gt;Rien à la main, ou alors documenté, si possible au même endroit que le gestionnaire de configuration&lt;/li&gt;
  &lt;li&gt;Bien sûr, sauvegardez ça aussi…&lt;/li&gt;
  &lt;li&gt;Faire des snapshoot des VM, ça permet de relancer le service plus vite sur un autre site, voir un autre hébergeur si l’hyperviseur est installable ailleurs&lt;/li&gt;
  &lt;li&gt;Et on teste de temps en temps&lt;/li&gt;
  &lt;li&gt;Mais surtout à chaque changement majeur ! (version d’OS / d’hyperviseur)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;le-continent-où-est-hébergé-le-serveur-disparaît&quot;&gt;Le continent où est hébergé le serveur disparaît&lt;/h3&gt;

&lt;p&gt;Bon, l’Europe est engloutie sous les mers telle l’Atlantide, on se fait atomiser par un météorite comme nos ancêtres les dinosaures. Là, je dois vous avouer que je n’ai pas adressé ce problème. Mais comme je serais mort….&lt;/p&gt;

&lt;h2 id=&quot;pour-résumer&quot;&gt;Pour résumer&lt;/h2&gt;

&lt;p&gt;Toutes les semaines :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Snapshoot des vm&lt;/li&gt;
  &lt;li&gt;Backup full de ma BDD&lt;/li&gt;
  &lt;li&gt;Transfert de tout ça sur le serveur de sauvegarde distant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tous les jours :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Backup de la BDD&lt;/li&gt;
  &lt;li&gt;Rsync des fichiers&lt;/li&gt;
  &lt;li&gt;Rsync des sauvegardes de BDD&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;le-serveur-de-sauvegarde&quot;&gt;Le serveur de sauvegarde&lt;/h2&gt;

&lt;p&gt;J’en parle, mais quoi et où ?&lt;/p&gt;

&lt;p&gt;Pour réduire les risques :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Chez un autre fournisseur&lt;/li&gt;
  &lt;li&gt;Un minimum de kilomètres entre les DC (on parle souvent de 300km), accident nucléaire, météorite, tremblement de terre …&lt;/li&gt;
  &lt;li&gt;C’est le serveur qui va chercher les sauvegardes (pull). Si le serveur de prod est compromis, il ne faut pas que l’attaquant puisse se connecter à ce serveur&lt;/li&gt;
  &lt;li&gt;Filtrez les IP qui peuvent se connecter&lt;/li&gt;
  &lt;li&gt;Et toute protection pour blinder ce serveur est bonne à mettre en place&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;et-ça-suffit-&quot;&gt;Et ça suffit ?&lt;/h2&gt;

&lt;p&gt;Ça dépend de votre niveau de parano. Un backup sur votre NAS c’est bien aussi. Mais dans ce cas là, pensez à le chiffrer.&lt;/p&gt;

&lt;h2 id=&quot;et-pourquoi-ne-pas-mettre-tout-ça-chez-moi-&quot;&gt;Et pourquoi ne pas mettre tout ça chez moi ?&lt;/h2&gt;

&lt;p&gt;C’est sûr qu’avec la fibre optique vous avez de plus en plus la possibilité de vous héberger. Sauf que :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Rentrer dans un DC est de plus en plus dur&lt;/li&gt;
  &lt;li&gt;Un DC qui brûle, c’est plutôt rare&lt;/li&gt;
  &lt;li&gt;Une coupure de fibre, ça arrive. Un DC a plusieurs arrivées, et des SLA garanties par les opérateurs, les techniciens vont donc ressouder les fibres très vite&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et chez vous ? Personnellement, je n’ai plus rien de critique chez moi. Au pire, je me fais voler/détruire ma workstation et sa sauvegarde.&lt;/p&gt;

&lt;p&gt;Et quand je parle d’intrusion, il y a le vol qui inclut la perte des données. Mais que se passerait-il si les données fuitaient par la suite ? GDPR et/ou concurrents ?&lt;/p&gt;

&lt;h1 id=&quot;et-maintenant-&quot;&gt;Et maintenant ?&lt;/h1&gt;

&lt;p&gt;Je pense que l’article est déjà suffisamment long. Mais je pense que vous avez l’idée. Avec tout ça, nous avons un Plan de Reprise d’Activité.&lt;/p&gt;

&lt;p&gt;Depuis que je mets tout ça en place, je dors beaucoup mieux. Je ne dis pas que je serais parfaitement serein si GRA/RBX brûlait, j’ai beaucoup plus de serveurs là-bas.&lt;/p&gt;

&lt;p&gt;Mais globalement, je pense avoir adressé pas mal de problèmes.&lt;/p&gt;

&lt;p&gt;Et à chaque nouvelle technologie, il faut se renouveler et recommencer cette analyse de risque.&lt;/p&gt;

&lt;p&gt;Comment je gère mes vm “cloud”, comment je sauvegarde mon object storage ?&lt;/p&gt;

&lt;p&gt;Nous n’avons pas non plus discuté du coût de ces contre-mesures, dans ce cas là, ce n’est pas vraiment négociable de faire sans. Par contre, nous n’avons pas parlé de Plan de Continuité d’Activité.&lt;/p&gt;

&lt;p&gt;En gros tout est déjà prêt au cas où le site principal est HS. Voir, ça bascule tout seul, mais ça, c’est une autre histoire et ne coûte PAS DU TOUT la même chose qu’un PRA…&lt;/p&gt;

&lt;p&gt;Et toi ? Tu gères tout ça comment ?&lt;/p&gt;

&lt;p&gt;Crédit des images :
&lt;a href=&quot;https://en.wikipedia.org/wiki/Linear_Tape-Open#/media/File:LTO2-cart-purple.jpg&quot;&gt;Cartouche de sauvegarde&lt;/a&gt;
&lt;a href=&quot;https://commons.wikimedia.org/wiki/Category:Data_centers#/media/File:CERN_Server_03.jpg&quot;&gt;DC&lt;/a&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Fire_ecology#/media/File:2011-08-04_20_00_00_Susie_Fire_in_the_Adobe_Range_west_of_Elko_Nevada.jpg&quot;&gt;Feu&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 22 Mar 2021 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/sauvegardes-analyse-de-risque-pra-et-pca/</link>
        <guid isPermaLink="true">https://blog.ledez.net/sauvegardes-analyse-de-risque-pra-et-pca/</guid>
        
        <category>Informatique</category>
        
        <category>securite</category>
        
        
        <category>Informatique</category>
        
        <category>Securite</category>
        
      </item>
    
      <item>
        <title>Générer des certificats wildcard avec Terraform</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/10/terraform_plus_letsencrypt.png&quot; alt=&quot;Terraform + Let's Encrypt&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Vous connaissez &lt;a href=&quot;https://www.terraform.io&quot;&gt;Terraform&lt;/a&gt; ? Et &lt;a href=&quot;https://letsencrypt.org&quot;&gt;Let’s Encrypt&lt;/a&gt; ?&lt;/p&gt;

&lt;p&gt;Le premier permet de gérer le cycle de vie de vos infrastructures. Et le deuxième vous permet d’avoir des certificats TLS signés par une autorité de certification valide dans les navigateurs modernes.&lt;/p&gt;

&lt;p&gt;Dans cet article, je vais vous montrer comment faire un certificat wildcard &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.mondomaine.tld&lt;/code&gt; avec Terraform. La validation avec le protocole acme la plus simple pour ces certificats, est via le DNS. Pour cela, je vais utiliser OVH puisque mon domaine de test est là-bas.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Bon, ce n’est pas le tout. Mais on n’est pas là pour beurrer des toasts.&lt;/p&gt;

&lt;p&gt;Déjà, on va récupérer le repository qui permet de faire tout ça :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/nledez/hashicorppourlesnoobs-sources.git demo-terraform-le
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;demo-terraform-le/terraform
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;install.sh                 ovh-create-consumer-key.py terraform.tf               variables.tf
lecertificate.tf           requirements.txt           terraform.tfvars&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;À quoi servent ces fichiers ?&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;install.sh&lt;/code&gt; -&amp;gt; installer les dépendances&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;requirements.txt&lt;/code&gt; -&amp;gt; les dépendances Python&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ovh-create-consumer-key.py&lt;/code&gt; -&amp;gt; un script pour simplifier la création du fichier ovh.conf et ovh.sh&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform.tf&lt;/code&gt; -&amp;gt; fichier Terraform qui définit la configuration des providers Terraform&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;variables.tf&lt;/code&gt; -&amp;gt; fichier Terraform qui définit les variables que l’on va utiliser dans notre plan Terraform&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform.tfvars&lt;/code&gt; -&amp;gt; fichier Terraform qui donne les valeurs que l’on va utiliser pour générer notre certificat TLS&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lecertificate.tf&lt;/code&gt; -&amp;gt; le plan Terraform qui permet de générer le certificat TLS chez Let’s Encrypt&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On va commencer par installer les prérequis pour causer avec l’API OVH et donc le DNS :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./install.sh
Running virtualenv with interpreter /usr/local/bin/python3
Already using interpreter /usr/local/opt/python/bin/python3.7
Using base prefix &lt;span class=&quot;s1&quot;&gt;'/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7'&lt;/span&gt;
New python executable &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /private/tmp/demo-terraform-le/terraform/.venv/bin/python3.7
Also creating executable &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /private/tmp/demo-terraform-le/terraform/.venv/bin/python
Installing setuptools, pip, wheel...
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
Collecting &lt;span class=&quot;nv&quot;&gt;ovh&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;0.5.0 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;from &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; requirements.txt &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;line 1&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;
  Using cached https://files.pythonhosted.org/packages/58/92/db708f5a2e105ca48da1ac065c0168c7626685f9ab3667184dc2d9772bb1/ovh-0.5.0-py2.py3-none-any.whl
Installing collected packages: ovh
Successfully installed ovh-0.5.0&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ça crée un virtualenv Python pour éviter de pourrir votre machine avec des libs Python. Puis installe la bibliothèque &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ovh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Maintenant, on va créer le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ovh.conf&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; ./.venv/bin/activate
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./ovh-create-consumer-key.py
Need to generate default ovh.conf
Go to https://eu.api.ovh.com/createApp/
Fill form get values and fill ovh.conf with:
application_key &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
application_secret &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
Now I quit&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Comme l’indique le script, il faut aller sur la page &lt;a href=&quot;https://eu.api.ovh.com/createApp/&quot;&gt;https://eu.api.ovh.com/createApp/&lt;/a&gt; pour créer le couple &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application_key&lt;/code&gt; &amp;amp; application_secret`.&lt;/p&gt;

&lt;p&gt;On va rentrer son login/pass OVH puis un nom d’application et une description :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/10/api-ovh-01.png&quot; alt=&quot;Création de clée d'API OVH/1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Une fois les application key/secret générées on va les copier pour les mettre dans le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ovh.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/10/api-ovh-02.png&quot; alt=&quot;Création de clée d'API OVH/2&quot; /&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi ovh.conf
application_key &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; XXXX
application_secret &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; XXXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;On relance le script qui va vérifier que le &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;consumer_key&lt;/code&gt; est encore valide. Et s’il n’est plus valide ou absent va nous en générer un nouveau.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./ovh-create-consumer-key.py
Need a valid consumer_key
Please visit https://eu.api.ovh.com/auth/?credentialToken&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;XXXXXXXX to authenticate
and press Enter to &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;...&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Là, soit on est sur un Mac, et ça ouvre automatiquement le lien. Sinon, il faut copier le lien et se connecter pour générer la &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;consumer_key&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On rentre son login/pass, puis valide.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/10/api-ovh-03.png&quot; alt=&quot;Création de clée d'API OVH/3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On peut fermer cette page, puis retourner sur le terminal.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/10/api-ovh-04.png&quot; alt=&quot;Création de clée d'API OVH/4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Une fois fait, appuyer sur entrée.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Welcome Nicolas
Btw, your &lt;span class=&quot;s2&quot;&gt;&quot;consumerKey&quot;&lt;/span&gt; is &lt;span class=&quot;s2&quot;&gt;&quot;XXXXX&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Le script nous a rendu la main, et a automatiquement mis à jour le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ovh.conf&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;ovh.conf
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;default]
endpoint &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; ovh-eu

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ovh-eu]
application_key &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; XXX
application_secret &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; XXX
consumer_key &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;On peut même vérifier que le &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;consumer_key&lt;/code&gt; est toujours valide :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./ovh-create-consumer-key.py
Welcome Nicolas nothing to &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;On va charger les variables d’environnement qui vont être utilisées par Terraform. Mais aussi éditer le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform.tfvars&lt;/code&gt; pour y mettre les bonnes valeurs.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; ./ovh.sh
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi terraform.tfvars&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parent_domain&lt;/code&gt; -&amp;gt; le nom de domaine racine pour le certificat. Dans mon cas &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hashicorp4noobs.fr&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subdomain&lt;/code&gt; -&amp;gt; le sous-domaine pour mon wildcard. Je vais mettre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tools&lt;/code&gt;. Au final, mon certificat sera sous la forme &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.tools.hashicorp4noobs.fr&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;le_email&lt;/code&gt; -&amp;gt; l’email auquel Let’s Encrypt va envoyer les messages quand le certificat va expirer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On va en profiter pour éditer le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;terraform.tf&lt;/code&gt; et utiliser le serveur de staging Let’s Encrypt (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server_url = &quot;https://acme-staging-v02.api.letsencrypt.org/directory&quot;&lt;/code&gt;)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi terraform.tf&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et il est maintenant temps d’initialiser Terraform :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;terraform init

Initializing the backend...

Initializing provider plugins...
- Checking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;available provider plugins...
- Downloading plugin &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;provider &lt;span class=&quot;s2&quot;&gt;&quot;tls&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;hashicorp/tls&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 2.1.1...
- Downloading plugin &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;provider &lt;span class=&quot;s2&quot;&gt;&quot;acme&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;terraform-providers/acme&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 1.4.0...
- Downloading plugin &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;provider &lt;span class=&quot;s2&quot;&gt;&quot;local&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;hashicorp/local&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 1.4.0...

The following providers &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;not have any version constraints &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;...&quot;&lt;/span&gt; constraints to the
corresponding provider blocks &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;configuration, with the constraint strings
suggested below.

&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; provider.acme: version &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;~&amp;gt; 1.4&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; provider.local: version &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;~&amp;gt; 1.4&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; provider.tls: version &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;~&amp;gt; 2.1&quot;&lt;/span&gt;

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running &lt;span class=&quot;s2&quot;&gt;&quot;terraform plan&quot;&lt;/span&gt; to see
any changes that are required &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;your infrastructure. All Terraform commands
should now work.

If you ever &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;or change modules or backend configuration &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;Terraform,
rerun this &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;to reinitialize your working directory. If you forget, other
commands will detect it and remind you to &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;so &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;necessary.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Tout s’est bien passé, on va attaquer la suite :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;terraform apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  &lt;span class=&quot;c&quot;&gt;# acme_certificate.certificate will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;acme_certificate&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + account_key_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + certificate_domain        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + certificate_p12           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + certificate_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + certificate_url           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + common_name               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*.tools.hashicorp4noobs.fr&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + issuer_pem                &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + key_type                  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2048&quot;&lt;/span&gt;
      + min_days_remaining        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 30
      + must_staple               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
      + private_key_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + subject_alternative_names &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
          + &lt;span class=&quot;s2&quot;&gt;&quot;tools.hashicorp4noobs.fr&quot;&lt;/span&gt;,
        &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

      + dns_challenge &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
          + provider &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ovh&quot;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# acme_registration.local_registration will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;acme_registration&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;local_registration&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + account_key_pem  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + email_address    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;letsencrypt@hashicorp4noobs.fr&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + registration_url &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_certificate will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt;
      + filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_certificate.pem&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_chain_certificate will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_chain_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt;
      + filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_chain_certificate.pem&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_issuer_certificate will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_issuer_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt;
      + filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_issuer_certificate.pem&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_private_key will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0600&quot;&lt;/span&gt;
      + filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key.pem&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_private_key_file will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key_file&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt;
      + filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;./le_account.key&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# tls_private_key.le_tls_private_key will be created&lt;/span&gt;
  + resource &lt;span class=&quot;s2&quot;&gt;&quot;tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      + algorithm                  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;RSA&quot;&lt;/span&gt;
      + ecdsa_curve                &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;P224&quot;&lt;/span&gt;
      + &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + private_key_pem            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + public_key_fingerprint_md5 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + public_key_openssh         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + public_key_pem             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;known after apply&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      + rsa_bits                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 4096
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

Plan: 8 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only &lt;span class=&quot;s1&quot;&gt;'yes'&lt;/span&gt; will be accepted to approve.

  Enter a value:&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;On tape &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yes&lt;/code&gt; puis entrée.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;tls_private_key.le_tls_private_key: Creating...
tls_private_key.le_tls_private_key: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 1s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;517c54bf80a1bf7d67506ad2a8c5bcadc6b80749]
acme_registration.local_registration: Creating...
local_file.le_tls_private_key_file: Creating...
local_file.le_tls_private_key_file: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;11d0b10f636c0e08e8bf51722544cb1242c1b4c3]
acme_registration.local_registration: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 3s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/acct/11286586]
acme_certificate.certificate: Creating...
acme_certificate.certificate: Still creating... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;10s elapsed]
acme_certificate.certificate: Still creating... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;20s elapsed]
acme_certificate.certificate: Still creating... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;30s elapsed]
acme_certificate.certificate: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 33s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa901221714abb3504588ce806a6b9838105]
local_file.le_tls_issuer_certificate: Creating...
local_file.le_tls_certificate: Creating...
local_file.le_tls_chain_certificate: Creating...
local_file.le_tls_private_key: Creating...
local_file.le_tls_issuer_certificate: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;b96fb4b4081d20c510fb1c6daa2256645cbc3c85]
local_file.le_tls_chain_certificate: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;a265e33f4ed96a3043e97f4a6f7356ce98877c09]
local_file.le_tls_private_key: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;387b4c339cde6e90d85143b11f0522435a03f174]
local_file.le_tls_certificate: Creation &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2f0c5d9161d44617802561a2a19cccff506492af]

Apply &lt;span class=&quot;nb&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; Resources: 8 added, 0 changed, 0 destroyed.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà, tout s’est bien passé. On peut vérifier que les fichiers sont bien là :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-1rt&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'^le'&lt;/span&gt;
lecertificate.tf
le_account.key
le_tls_certificate.pem
le_tls_private_key.pem
le_tls_issuer_certificate.pem
le_tls_chain_certificate.pem&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Comme c’était un test, on peut tout supprimer :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;terraform destroy
tls_private_key.le_tls_private_key: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;517c54bf80a1bf7d67506ad2a8c5bcadc6b80749]
local_file.le_tls_private_key_file: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;11d0b10f636c0e08e8bf51722544cb1242c1b4c3]
acme_registration.local_registration: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/acct/11286586]
acme_certificate.certificate: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa901221714abb3504588ce806a6b9838105]
local_file.le_tls_issuer_certificate: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;b96fb4b4081d20c510fb1c6daa2256645cbc3c85]
local_file.le_tls_certificate: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2f0c5d9161d44617802561a2a19cccff506492af]
local_file.le_tls_private_key: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;387b4c339cde6e90d85143b11f0522435a03f174]
local_file.le_tls_chain_certificate: Refreshing state... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;a265e33f4ed96a3043e97f4a6f7356ce98877c09]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  &lt;span class=&quot;c&quot;&gt;# acme_certificate.certificate will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;acme_certificate&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - account_key_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      - certificate_domain        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*.tools.hashicorp4noobs.fr&quot;&lt;/span&gt; -&amp;gt; null
      - certificate_p12           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      - certificate_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - certificate_url           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa901221714abb3504588ce806a6b9838105&quot;&lt;/span&gt; -&amp;gt; null
      - common_name               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*.tools.hashicorp4noobs.fr&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa901221714abb3504588ce806a6b9838105&quot;&lt;/span&gt; -&amp;gt; null
      - issuer_pem                &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - key_type                  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2048&quot;&lt;/span&gt; -&amp;gt; null
      - min_days_remaining        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 30 -&amp;gt; null
      - must_staple               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; -&amp;gt; null
      - private_key_pem           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      - subject_alternative_names &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
          - &lt;span class=&quot;s2&quot;&gt;&quot;tools.hashicorp4noobs.fr&quot;&lt;/span&gt;,
        &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; -&amp;gt; null

      - dns_challenge &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
          - config   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
          - provider &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ovh&quot;&lt;/span&gt; -&amp;gt; null
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# acme_registration.local_registration will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;acme_registration&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;local_registration&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - account_key_pem  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      - email_address    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;letsencrypt@hashicorp4noobs.fr&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;               &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://acme-staging-v02.api.letsencrypt.org/acme/acct/XXXX&quot;&lt;/span&gt; -&amp;gt; null
      - registration_url &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://acme-staging-v02.api.letsencrypt.org/acme/acct/XXXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_certificate will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt; -&amp;gt; null
      - filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_certificate.pem&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_chain_certificate will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_chain_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt; -&amp;gt; null
      - filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_chain_certificate.pem&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_issuer_certificate will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_issuer_certificate&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END CERTIFICATE-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0644&quot;&lt;/span&gt; -&amp;gt; null
      - filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_issuer_certificate.pem&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_private_key will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN RSA PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END RSA PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0600&quot;&lt;/span&gt; -&amp;gt; null
      - filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key.pem&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# local_file.le_tls_private_key_file will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;local_file&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key_file&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - content              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN RSA PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END RSA PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - directory_permission &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - file_permission      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0777&quot;&lt;/span&gt; -&amp;gt; null
      - filename             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;./le_account.key&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;# tls_private_key.le_tls_private_key will be destroyed&lt;/span&gt;
  - resource &lt;span class=&quot;s2&quot;&gt;&quot;tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;le_tls_private_key&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      - algorithm                  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;RSA&quot;&lt;/span&gt; -&amp;gt; null
      - ecdsa_curve                &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;P224&quot;&lt;/span&gt; -&amp;gt; null
      - &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;                         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
      - private_key_pem            &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;sensitive value&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
      - public_key_fingerprint_md5 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
      - public_key_openssh         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;XXX&quot;&lt;/span&gt; -&amp;gt; null
      - public_key_pem             &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN PUBLIC KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[...]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END PUBLIC KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; -&amp;gt; null
      - rsa_bits                   &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 4096 -&amp;gt; null
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

Plan: 0 to add, 0 to change, 8 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only &lt;span class=&quot;s1&quot;&gt;'yes'&lt;/span&gt; will be accepted to confirm.

  Enter a value: &lt;span class=&quot;nb&quot;&gt;yes

&lt;/span&gt;local_file.le_tls_issuer_certificate: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;b96fb4b4081d20c510fb1c6daa2256645cbc3c85]
local_file.le_tls_chain_certificate: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;a265e33f4ed96a3043e97f4a6f7356ce98877c09]
local_file.le_tls_private_key_file: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;11d0b10f636c0e08e8bf51722544cb1242c1b4c3]
local_file.le_tls_private_key: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;387b4c339cde6e90d85143b11f0522435a03f174]
local_file.le_tls_certificate: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2f0c5d9161d44617802561a2a19cccff506492af]
local_file.le_tls_private_key_file: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s
local_file.le_tls_certificate: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s
local_file.le_tls_private_key: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s
local_file.le_tls_issuer_certificate: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s
local_file.le_tls_chain_certificate: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s
acme_certificate.certificate: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/cert/fa901221714abb3504588ce806a6b9838105]
acme_certificate.certificate: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 2s
acme_registration.local_registration: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://acme-staging-v02.api.letsencrypt.org/acme/acct/11286586]
acme_registration.local_registration: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 1s
tls_private_key.le_tls_private_key: Destroying... &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;517c54bf80a1bf7d67506ad2a8c5bcadc6b80749]
tls_private_key.le_tls_private_key: Destruction &lt;span class=&quot;nb&quot;&gt;complete &lt;/span&gt;after 0s

Destroy &lt;span class=&quot;nb&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; Resources: 8 destroyed.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà, vous savez :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Utiliser Terraform&lt;/li&gt;
  &lt;li&gt;Avec Let’s encrypt&lt;/li&gt;
  &lt;li&gt;Créer des fichiers en local&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Si votre DNS n’est pas chez OVH, vous pouvez changer le &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns_challenge&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;provider = &quot;ovh&quot;&lt;/code&gt; dans le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lecertificate.tf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Voici la &lt;a href=&quot;https://www.terraform.io/docs/providers/acme/dns_providers/index.html&quot;&gt;liste des providers DNS&lt;/a&gt; ainsi que leurs documentations respectives.&lt;/p&gt;
</description>
        <pubDate>Wed, 09 Oct 2019 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/informatique/générer-des-certificats-wildcard-avec-terraform/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/générer-des-certificats-wildcard-avec-terraform/</guid>
        
        <category>Informatique</category>
        
        <category>Terraform</category>
        
        <category>Letsencrypt</category>
        
        
        <category>Informatique</category>
        
      </item>
    
      <item>
        <title>How to recover a 'rm -rf /var/lib/mysql/*'</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/09/MysqlCrash.jpg&quot; alt=&quot;Mysql crash&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There’s a saying I like:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;In life, there are two types of system administrators:
The one who has already made a big mistake in production
And the one that will soon be&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well, I just moved from the second to the first category in a command line:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/lib/mysql
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And of course on the production server, and not on the future one.&lt;/p&gt;

&lt;p&gt;In short, the BIG dumpling. On an 80GB database that takes several hours to restore.&lt;/p&gt;

&lt;p&gt;And very big spoiler, we managed to restore everything.&lt;/p&gt;

&lt;p&gt;Before I read on, I don’t guarantee that this will work for you. And declines any responsibility if you lose your data.&lt;/p&gt;

&lt;p&gt;But you may be happy to be able to get as much of your bases/tables as possible.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;First of all, the first thing to do is to cut off any activity that may be present on this instance:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Shutdown applications can access to Mysql&lt;/li&gt;
  &lt;li&gt;Put an iptable rule&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whatever, but above all, reduce access to this instance.&lt;/p&gt;

&lt;p&gt;The second thing to keep in mind, DO NOT STOP Mysql. That’s what’s going to save us.&lt;/p&gt;

&lt;p&gt;I have since written a Python script that will allow me to save as much as possible.&lt;/p&gt;

&lt;p&gt;Then I will quickly explain why all this can work.&lt;/p&gt;

&lt;p&gt;But first, here’s how to reproduce this in your home (in a Vagant). Don’t try that on a real server.&lt;/p&gt;

&lt;h1 id=&quot;setting-up-the-test-environment&quot;&gt;Setting up the test environment&lt;/h1&gt;

&lt;p&gt;We’re going to use &lt;a href=&quot;https://www.vagrantup.com&quot;&gt;Vagrant&lt;/a&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone https://github.com/nledez/recover_deleted_mysql.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;recover_deleted_mysql
vagrant up
vagrant ssh
&lt;span class=&quot;c&quot;&gt;# From there, we are in the Vagrant VM.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Before doing dangerous operations, make sure you are always there...&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# The prompt must be: vagrant@ubuntu-bionic&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# We're going to load test data into Mysql&lt;/span&gt;
git clone https://github.com/datacharmer/test_db.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;test_db
&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;employees.sql | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql

&lt;span class=&quot;c&quot;&gt;# We display the list of bases to check that the import has worked well&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql

&lt;span class=&quot;c&quot;&gt;# We'll make a backup for later (you still need one, and it will allow you to restart the test from there)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql stop
&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /backup
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rsync &lt;span class=&quot;nt&quot;&gt;-av&lt;/span&gt; /var/lib/mysql/ /backup/
&lt;span class=&quot;nb&quot;&gt;sudo chmod &lt;/span&gt;777 /backup
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql start
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;bash /vagrant/read_all_data.sh
&lt;span class=&quot;c&quot;&gt;# The last command lists all the data from all the tables, so that everything can be loaded into memory.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# It's time to destroy all database files (it's especially that part you never do in production)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; d &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rmdir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Ouupppsss&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-la&lt;/span&gt; /var/lib/mysql/
&lt;span class=&quot;c&quot;&gt;# And now we're going to check that it's the big shit in production:&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;were-going-to-start-the-restoration&quot;&gt;We’re going to start the restoration:&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# We create a directory in which we will put the files we will recover (we will need the place of the old /var/lib/mysql)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /recover
&lt;span class=&quot;c&quot;&gt;# We're going to get the PID from the Mysql process&lt;/span&gt;
ps ax | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;m]ysqld
&lt;span class=&quot;c&quot;&gt;# We will store it in a variable (it's easier for the rest of the article)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;MYSQL_PID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2530
&lt;span class=&quot;c&quot;&gt;# We're going to do a `lsof` that will show us why we're going to be able to recover the disaster&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lsof &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;and-now-lets-let-the-magic-work&quot;&gt;And now, let’s let the magic work.&lt;/h2&gt;

&lt;h3 id=&quot;the-script-in---help-mode&quot;&gt;The script in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--help&lt;/code&gt; mode&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
usage: recover_deleted_mysql.py &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; PID &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; RECOVER_PATH]
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; MYSQL_PATH] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; EXPORT_AS_CSV &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;EXPORT_AS_CSV ...]]
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; CSV_PATH]

Mysql recuperator

optional arguments:
  &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;            show this &lt;span class=&quot;nb&quot;&gt;help &lt;/span&gt;message and &lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; PID             PID of Mysql process
  &lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; RECOVER_PATH
                        Path of directory &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;you want revover deleted files
  &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; MYSQL_PATH
                        Path of mysql directory &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;you want limit recovery
  &lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;         If you want &lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;deleted files
  &lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; EXPORT_AS_CSV &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;EXPORT_AS_CSV ...]
                        List of databases to &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;require &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt;
                        argument
  &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; CSV_PATH   Path of csv &lt;span class=&quot;nb&quot;&gt;export&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;recovery-of-deleted-files&quot;&gt;Recovery of deleted files&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; /recover
&lt;span class=&quot;c&quot;&gt;# And we can check with the command `sudo find /recover -ls`&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;extraction-of-data-in-csv-formats-for-greater-security&quot;&gt;Extraction of data in CSV formats for greater security&lt;/h3&gt;

&lt;p&gt;Well, if the database is ever corrupted, we’ll be happy to have the data in CSV format.
However, in my tests, I had a lot of crashes with the Mysql engine, so you have to be very careful with the controls.
But also to think that it might crash and that we’ll lose everything.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# First step, we'll do a touch of the files that have been deleted (yes, it sounds stupid, but it works)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# VERY important, change the permissions of directories and files before doing anything (this is where Mysql can crash)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;c&quot;&gt;# Now, we can list the DBs&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql
&lt;span class=&quot;c&quot;&gt;# But we don't see the tables yet&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show tables;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql employees
&lt;span class=&quot;c&quot;&gt;# We need the.frm files that contain the table structures (so we need a backup of these files on hand)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /backup/
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'*.frm'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; /var/lib/mysql/&lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show tables;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql employees
&lt;span class=&quot;c&quot;&gt;# And now we can make selections in the tables. But no mysqldump and especially in my tests, it made Mysql crash :(&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# DO NOT start mysqldump until you have finished all this&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# In a &quot;normal&quot; installation, Mysql cannot write a file anywhere. We're going to look for the path that's configured:&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'SHOW VARIABLES LIKE &quot;secure_file_priv&quot;;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql &lt;span class=&quot;c&quot;&gt;# Get /var/lib/mysql-files/&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# And we start exporting&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; /var/lib/mysql-files &lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; employees&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And voilà!&lt;/p&gt;

&lt;h3 id=&quot;put-the-data-back-in-place&quot;&gt;Put the data back in place&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# Restored files are copied to the Mysql directory:&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rsync &lt;span class=&quot;nt&quot;&gt;-av&lt;/span&gt; /recover/var/lib/mysql/ /var/lib/mysql/
&lt;span class=&quot;c&quot;&gt;# We're arresting Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql stop
&lt;span class=&quot;c&quot;&gt;# We give the right rights back&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;c&quot;&gt;# We're relaunching Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql start
&lt;span class=&quot;c&quot;&gt;# We're asking Mysql to do a check of the databases&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysqlcheck &lt;span class=&quot;nt&quot;&gt;--all-databases&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Launch a `mysql_upgrade` that restores all system bases/tables to working order&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql_upgrade
&lt;span class=&quot;c&quot;&gt;# We're relaunching Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql restart
&lt;span class=&quot;c&quot;&gt;# We restart a Mysqldump to make sure that the database works again well&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd
sudo &lt;/span&gt;mysqldump employees &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; employees.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;various-instructions&quot;&gt;Various instructions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Never stop Mysql, never, never, never, never, never, never, never, never, never&lt;/li&gt;
  &lt;li&gt;Do not try to mysqldump while using this tool, never (again)&lt;/li&gt;
  &lt;li&gt;We identify the mysql process with the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps ax | grep[m]ysqld&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;We should only have one process. Write it down for later&lt;/li&gt;
  &lt;li&gt;We’ll check the files we can recover &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo lsof -p $MYSQL_PID&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;We can see all the files deleted&lt;/li&gt;
  &lt;li&gt;And as long as we have Mysql running, we’ll be able to get those files back&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;why-it-can-work&quot;&gt;Why it can work&lt;/h1&gt;

&lt;p&gt;Already, it is necessary to understand how Linux works in ext* when deleting a file.&lt;/p&gt;

&lt;p&gt;We’re going back to the base. When a process opens a file, it opens an FD “file descriptor” in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lsof&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A file is defined in the ext* file system as a path that points to an inode.&lt;/p&gt;

&lt;p&gt;When you delete a file, you delete this link in the file allocation table.&lt;/p&gt;

&lt;p&gt;And ext* frees up the space when an inode no longer has an FD open on the inode.&lt;/p&gt;

&lt;p&gt;That’s why sometimes you delete a large file, but the space is not cleared.&lt;/p&gt;

&lt;p&gt;Or when you make a `mv’ of a log file, touch the new file and the process continues to write to the file that has been renamed. The FD is still open on the old inode. It hurts a little bit of a headache, doesn’t it?&lt;/p&gt;

&lt;p&gt;And so since Mysql keeps the files open, we can make a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat /proc/$PID/df/9&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So much for the recovery part of the deleted files.&lt;/p&gt;

&lt;p&gt;Now, the stories around &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is the part I have less control over, but I can imagine Mysql’s behavior.&lt;/p&gt;

&lt;p&gt;When doing a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show databases;&lt;/code&gt; Mysql must read the list of directories in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/lib/mysql&lt;/code&gt;. That’s why you can end up with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lost+found&lt;/code&gt; database.&lt;/p&gt;

&lt;p&gt;Then when we do a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show tables;&lt;/code&gt; Mysql must read the list of files &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.MYI&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.MYD&lt;/code&gt; (or both, or when one misses mysql may be crash). So a touch of the files brings up the tables. But since the files are already open, he will be able to access the old deleted files content.&lt;/p&gt;

&lt;p&gt;However, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;desc table&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select&lt;/code&gt; will not work. For this purpose Mysql needs the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.frm&lt;/code&gt; files that contain the table structure. And here, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frm/MYD/MYI&lt;/code&gt; files must be properly aligned.&lt;/p&gt;

&lt;p&gt;That’s it, we only have the Mysqldump that doesn’t work. I think he tries to read directly into the content of the files and that the `touch’ mess disturbs him.&lt;/p&gt;

&lt;p&gt;I’m done with this article. I hope I taught you some things. That you’ll never have to put all this into practice on production.&lt;/p&gt;

&lt;p&gt;And if I have any advice to give:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Make backups&lt;/li&gt;
  &lt;li&gt;Testing restorations&lt;/li&gt;
  &lt;li&gt;Note the time of these operations to be aware of the time it will take in case of a crash&lt;/li&gt;
  &lt;li&gt;If you do mysqldump, also think about making regular backups of.frm files&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 16 Sep 2019 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/informatique/how-to-recover-a-rm-rf-var-lib-mysql/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/how-to-recover-a-rm-rf-var-lib-mysql/</guid>
        
        <category>Informatique</category>
        
        <category>sysadmin</category>
        
        <category>Mysql</category>
        
        
        <category>Informatique</category>
        
      </item>
    
      <item>
        <title>Comment récupérer un 'rm -rf /var/lib/mysql/*'</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/09/MysqlCrash.jpg&quot; alt=&quot;Mysql crash&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Il y a un dicton que j’aime bien :&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Dans la vie, il y a deux types d’administrateurs système :&lt;/p&gt;
  &lt;ul&gt;
    &lt;li&gt;Celui qui a déjà fait une grosse connerie en production&lt;/li&gt;
    &lt;li&gt;Et celui que ne va pas tarder&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Et bien je viens de passer de la deuxième à la première catégorie en une ligne de commande :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/lib/mysql
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et bien entendu sur le serveur de production, et pas sur la future prod.&lt;/p&gt;

&lt;p&gt;Bref, la GROSSE boulette. Sur une BDD de 80Go qui prend plusieurs heures à restaurer.&lt;/p&gt;

&lt;p&gt;Et bien gros spoiler, nous avons réussi à tout restaurer.&lt;/p&gt;

&lt;p&gt;Avant de lire la suite, je ne garantis pas que cela va fonctionner chez vous. Et décline toute responsabilité si vous perdez vos données.&lt;/p&gt;

&lt;p&gt;Mais vous serez peut-être content de pouvoir récupéré un maximum de vos bases/tables.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Déjà, le premier truc à faire, c’est couper toute activité qu’il pourrait y avoir sur cette instance :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Couper l’application&lt;/li&gt;
  &lt;li&gt;Mettre une règle iptable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Peut importe, mais surtout réduire les accès à cette instance.&lt;/p&gt;

&lt;p&gt;Le deuxième truc à avoir en tête, NE PAS ARRÊTER Mysql. C’est ce qui va nous sauver.&lt;/p&gt;

&lt;p&gt;J’ai depuis écrit un script Python qui va permettre de sauvegarder un maximum de chose.&lt;/p&gt;

&lt;p&gt;Ensuite, je vais rapidement expliquer pourquoi tout cela peut fonctionner.&lt;/p&gt;

&lt;p&gt;Mais d’abord, voici comment reproduire ça chez vous (dans un Vagant). N’essayez pas ça sur un vrai serveur.&lt;/p&gt;

&lt;h1 id=&quot;mise-en-place-de-lenvironnement-de-test&quot;&gt;Mise en place de l’environnement de test&lt;/h1&gt;

&lt;p&gt;On va utiliser &lt;a href=&quot;https://www.vagrantup.com&quot;&gt;Vagrant&lt;/a&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone https://github.com/nledez/recover_deleted_mysql.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;recover_deleted_mysql
vagrant up
vagrant ssh
&lt;span class=&quot;c&quot;&gt;# À partir de là, nous sommes dans la VM Vagrant.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Avant de faire des opérations dangereuses, assurez-vous de toujours y être...&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Le prompt doit être : vagrant@ubuntu-bionic&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# On va charger des données dans Mysql&lt;/span&gt;
git clone https://github.com/datacharmer/test_db.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;test_db
&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;employees.sql | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql

&lt;span class=&quot;c&quot;&gt;# On affiche la liste de bases pour vérifier que l'import à bien fonctionné&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql

&lt;span class=&quot;c&quot;&gt;# On va faire un backup pour plus tard (il en faut toujours un, et ça va permettre de redémarrer le test à partir de là)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql stop
&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /backup
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rsync &lt;span class=&quot;nt&quot;&gt;-av&lt;/span&gt; /var/lib/mysql/ /backup/
&lt;span class=&quot;nb&quot;&gt;sudo chmod &lt;/span&gt;777 /backup
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql start
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;bash /vagrant/read_all_data.sh
&lt;span class=&quot;c&quot;&gt;# La dernière commande permet de lister toutes les données de toutes les tables, ça permet de tout charger en mémoire.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Il est temps de détruire la BDD (C'est surtout cette partie là à ne jamais faire en prod)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; d &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rmdir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Ouupppsss&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-la&lt;/span&gt; /var/lib/mysql/
&lt;span class=&quot;c&quot;&gt;# Et maintenant, on va vérifier que c'est bien la grosse merde en prod :&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;on-va-démarrer-la-restauration-&quot;&gt;On va démarrer la restauration :&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# On crée un répertoire dans lequel on va mettre les fichiers que l'on va récupérer (il faudra la place de l'ancien /var/lib/mysql)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /recover
&lt;span class=&quot;c&quot;&gt;# On va récupérer le PID du process Mysql&lt;/span&gt;
ps ax | &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;m]ysqld
&lt;span class=&quot;c&quot;&gt;# On va le stocker dans une variable (c'est plus simple pour le reste de l'article)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;MYSQL_PID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2530
&lt;span class=&quot;c&quot;&gt;# On va faire un `lsof` qui va nous montrer pourquoi on va pouvoir récupérer la catastrophe&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;lsof &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;et-maintenant-laissons-opérer-la-magie&quot;&gt;Et maintenant, laissons opérer la magie&lt;/h2&gt;

&lt;h3 id=&quot;le-script-en-mode---help&quot;&gt;Le script en mode &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--help&lt;/code&gt;&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
usage: recover_deleted_mysql.py &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; PID &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; RECOVER_PATH]
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; MYSQL_PATH] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; EXPORT_AS_CSV &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;EXPORT_AS_CSV ...]]
                                &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; CSV_PATH]

Mysql recuperator

optional arguments:
  &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;            show this &lt;span class=&quot;nb&quot;&gt;help &lt;/span&gt;message and &lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; PID             PID of Mysql process
  &lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; RECOVER_PATH
                        Path of directory &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;you want revover deleted files
  &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; MYSQL_PATH
                        Path of mysql directory &lt;span class=&quot;k&quot;&gt;if &lt;/span&gt;you want limit recovery
  &lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;         If you want &lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;deleted files
  &lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; EXPORT_AS_CSV &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;EXPORT_AS_CSV ...]
                        List of databases to &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;require &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt;
                        argument
  &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; CSV_PATH   Path of csv &lt;span class=&quot;nb&quot;&gt;export&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;récupération-des-fichiers-supprimés&quot;&gt;Récupération des fichiers supprimés&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;--recover_path&lt;/span&gt; /recover
&lt;span class=&quot;c&quot;&gt;# Et on peux vérifier avec la commande `sudo find /recover -ls`&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;extraction-des-données-aux-formats-csv-pour-plus-de-sécurité&quot;&gt;Extraction des données aux formats CSV pour plus de sécurité&lt;/h3&gt;

&lt;p&gt;Bon, si jamais la BDD est corrompue, on sera bien content d’avoir les données au format CSV.
Par contre, dans mes tests, j’ai eu beaucoup de crash du moteur Mysql, il faut donc être très prudent dans les commandes.
Mais aussi se dire que ça risque de planter et que l’on va tout perdre.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# Première étape, on va faire un touch des fichiers qui ont été supprimés (oui, ca parait débile, mais pourtant ça fonctionne)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--mysql_path&lt;/span&gt; /var/lib/mysql &lt;span class=&quot;nt&quot;&gt;--touch_files&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# TRÈS important, changer les droits des répertoires et fichiers avant de faire quoi que ce soit (c'est là que Mysql peut planter)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;c&quot;&gt;# Maintenant, on peut lister les BDD&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show databases;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql
&lt;span class=&quot;c&quot;&gt;# Mais on ne voit pas encore les tables&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show tables;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql employees
&lt;span class=&quot;c&quot;&gt;# Il nous faut les fichiers .frm qui contiennent les structures des tables (il faut donc avoir un backup de ces fichiers sous la main)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /backup/
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;find &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'*.frm'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; /var/lib/mysql/&lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'show tables;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql employees
&lt;span class=&quot;c&quot;&gt;# Et maintenant, on peut faire des select dans les tables. Mais pas de mysqldump et surtout dans mes tests, ça a fait cracher Mysql :(&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# NE PAS LANCER de mysqldump avant d'avoir terminé tout ça&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Dans une installation &quot;normal&quot;, Mysql ne peut pas écrire de fichier n'importe où. On va aller chercher le chemin qui est configuré :&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'SHOW VARIABLES LIKE &quot;secure_file_priv&quot;;'&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql &lt;span class=&quot;c&quot;&gt;# Get /var/lib/mysql-files/&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Et on lance l'export&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; /vagrant/recover_deleted_mysql.py &lt;span class=&quot;nt&quot;&gt;--pid&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$MYSQL_PID&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--csv_path&lt;/span&gt; /var/lib/mysql-files &lt;span class=&quot;nt&quot;&gt;--export_as_csv&lt;/span&gt; employees&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà !&lt;/p&gt;

&lt;h3 id=&quot;remettre-les-données-en-place&quot;&gt;Remettre les données en place&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# On copie les fichiers restaurés dans le répertoire Mysql :&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;rsync &lt;span class=&quot;nt&quot;&gt;-av&lt;/span&gt; /recover/var/lib/mysql/ /var/lib/mysql/
&lt;span class=&quot;c&quot;&gt;# On arrête Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql stop
&lt;span class=&quot;c&quot;&gt;# On remet les bons droits&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; mysql:mysql /var/lib/mysql
&lt;span class=&quot;c&quot;&gt;# On relance Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql start
&lt;span class=&quot;c&quot;&gt;# On demande à Mysql de faire un check des bases&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysqlcheck &lt;span class=&quot;nt&quot;&gt;--all-databases&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# On lance un `mysql_upgrade` qui remet toutes les bases/tables système en état de marche&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql_upgrade
&lt;span class=&quot;c&quot;&gt;# On relance Mysql&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;service mysql restart
&lt;span class=&quot;c&quot;&gt;# On relance un Mysqldump pour être bien sûr que la BDD refonctionne bien&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd
sudo &lt;/span&gt;mysqldump employees &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; employees.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;diverses-instructions&quot;&gt;Diverses instructions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Ne jamais arrêter Mysql, jamais, jamais, jamais, jamais, jamais, jamais&lt;/li&gt;
  &lt;li&gt;Ne pas essayer de mysqldump pendant que l’on utilise cet outil, jamais (encore une fois)&lt;/li&gt;
  &lt;li&gt;On identifie le process mysql avec la commande &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps ax | grep [m]ysqld&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;On ne doit avoir qu’un seul process. Le noter pour plus tard&lt;/li&gt;
  &lt;li&gt;On va vérifier les fichiers que l’on va pouvoir récupérer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo lsof -p $MYSQL_PID&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;On peut voir tous les fichiers ‘(deleted)’&lt;/li&gt;
  &lt;li&gt;Et tant que l’on a Mysql qui est lancé, on va pouvoir récupérer ces fichiers&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;pourquoi-ça-peut-fonctionner&quot;&gt;Pourquoi ça peut fonctionner&lt;/h1&gt;

&lt;p&gt;Déjà, il faut comprendre comment fonctionne Linux en ext* au moment de la suppression d’un fichier.&lt;/p&gt;

&lt;p&gt;On va revenir à la base. Quand un process ouvre un fichier, il ouvre un “file descriptor” FD dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lsof&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Un fichier, c’est défini dans le système de fichier ext* comme un chemin qui pointe vers un inode.&lt;/p&gt;

&lt;p&gt;Quand on supprime un fichier, on supprime ce lien dans la table d’allocation des fichiers.&lt;/p&gt;

&lt;p&gt;Et ext* libère la place quand un inode n’a plus de FD ouvert sur l’inode.&lt;/p&gt;

&lt;p&gt;C’est pour ça que des fois, on supprime un gros fichier, mais que la place n’est pas libérée.&lt;/p&gt;

&lt;p&gt;Ou encore quand on fait un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mv&lt;/code&gt; d’un fichier de log, un touch du nouveau fichier et que le process continue à écrire dans le fichier qui a été renommé. Le FD est toujours ouvert sur l’ancien inode. Ça fait un peu mal à la tête hein ?&lt;/p&gt;

&lt;p&gt;Et donc comme Mysql garde les fichiers ouverts, on peut faire un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat /proc/$PID/df/9&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Voilà pour la partie récupération des fichiers supprimés.&lt;/p&gt;

&lt;p&gt;Maintenant, les histoires de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;C’est la partie que je maîtrise moins, mais j’imagine le comportement de Mysql.&lt;/p&gt;

&lt;p&gt;Quand on fait un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show databases;&lt;/code&gt; Mysql doit lire la liste des répertoires dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/lib/mysql&lt;/code&gt;. C’est pour ça que l’on peut se retrouver avec une base de donnés &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lost+found&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Ensuite quand on fait un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show tables;&lt;/code&gt; Mysql doit lire la liste des fichiers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.MYI&lt;/code&gt; ou &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.MYD&lt;/code&gt; (ou les deux, ou quand l’un manque ça doit planter). Donc un touch des fichiers fait apparaître les tables. Mais comme les fichiers sont déjà ouverts, il va pouvoir accéder aux contenu des anciens fichiers supprimés.&lt;/p&gt;

&lt;p&gt;Par contre un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;desc table&lt;/code&gt; ou un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;select&lt;/code&gt; ne va pas fonctionner. Pour cela Mysql a besoin des fichiers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.frm&lt;/code&gt; qui contiennent la structure des tables. Et là, il faut que les fichiers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frm/MYD/MYI&lt;/code&gt; soient bien alignés.&lt;/p&gt;

&lt;p&gt;Voilà, il ne nous reste que le Mysqldump qui ne fonctionne pas. Je pense qu’il essaye de lire directement dans le contenu des fichiers et que la bidouille avec les &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt; le perturbe.&lt;/p&gt;

&lt;p&gt;J’en ai fini pour cet article. J’espère vous avoir appris des trucs. Que vous n’aurez jamais besoin de mettre tout ça en pratique sur de la prod.&lt;/p&gt;

&lt;p&gt;Et si j’ai des conseils à donner :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Faire des backup&lt;/li&gt;
  &lt;li&gt;Tester les restaurations&lt;/li&gt;
  &lt;li&gt;Noter le temps de ces opérations pour avoir conscience du temps que cela va prendre en cas de crash&lt;/li&gt;
  &lt;li&gt;Si vous faites des mysqldump, pensez à aussi faire des sauvegardes des .frm régulièrement&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 16 Sep 2019 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/informatique/comment-récupérer-un-rm-rf-var-lib-mysql/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/comment-récupérer-un-rm-rf-var-lib-mysql/</guid>
        
        <category>Informatique</category>
        
        <category>sysadmin</category>
        
        <category>Mysql</category>
        
        
        <category>Informatique</category>
        
      </item>
    
      <item>
        <title>Serveur iPXE ou comment booter sans USB/CD/whatever</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/05/bootroms.jpeg&quot; alt=&quot;iPXE&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Serveur iPXE ou comment booter sans USB/CD/whatever&lt;/p&gt;

&lt;p&gt;Avant, quand je voulais (ré)installer une machine, je gravais un CD (bien personnalisé à coup de mkisofs).
Ensuite, je suis passé aux clés USB.&lt;/p&gt;

&lt;p&gt;Mais c’est toujours pénible :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Il faut retrouver un média de libre&lt;/li&gt;
  &lt;li&gt;Il faut construire une image&lt;/li&gt;
  &lt;li&gt;Il faut graver/flasher l’image sur le média&lt;/li&gt;
  &lt;li&gt;Booter sur le device&lt;/li&gt;
  &lt;li&gt;Et quand ça ne fonctionne pas, repasser par la case construire l’image&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bref, ce n’est pas pratique.&lt;/p&gt;

&lt;p&gt;On va donc passer à quelque chose de moderne comme (i)PXE.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Un peu de lecture pour comprendre ce que c’est :&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://fr.wikipedia.org/wiki/Preboot_Execution_Environment&quot;&gt;Définition Wikipedia de Preboot Execution Environment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;TL;DR donc, pour résumer c’est :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Le BIOS démarre&lt;/li&gt;
  &lt;li&gt;Il passe par le firmware de la carte réseau (boot menu &amp;amp; NIC)&lt;/li&gt;
  &lt;li&gt;Le firmware PXE fait une requête DHCP qui lui donne les informations
    &lt;ul&gt;
      &lt;li&gt;IP&lt;/li&gt;
      &lt;li&gt;Serveur BOOTP (TFTP pour simplifier)&lt;/li&gt;
      &lt;li&gt;Le nom de l’image avec laquelle booter&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;PXE télécharge l’image en TFTP&lt;/li&gt;
  &lt;li&gt;PXE boot l’image&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ça, c’était bien quand j’avais un NAS avec tout ce qu’il fallait comme stockage. Mais je suis passé sur un &lt;a href=&quot;https://pcengines.ch/apu2.htm&quot;&gt;APU2&lt;/a&gt; avec &lt;a href=&quot;https://opnsense.org/&quot;&gt;OpenSense&lt;/a&gt;. Je suis donc passé de 6To de stockage à 13Go en SDD. Par contre, je suis aussi passé d’un ASDL faiblar à de la fibre qui met le datacenter d’&lt;a href=&quot;https://www.ovh.com/fr/serveurs_dedies/&quot;&gt;OVH&lt;/a&gt; dans mon salon.&lt;/p&gt;

&lt;p&gt;Il me fallait donc une solution pour booter à partir d’une machine sur Internet.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ipxe.org/start&quot;&gt;iPXE&lt;/a&gt; arrive à la rescousse. C’est une version open source (c’est un point positif) de firmware PXE. Mais surtout avec beaucoup plus de fonctionnalités (et c’est là que ça devient intéressant). Comme la possibilité de télécharger les images en HTTP à la place de TFTP.&lt;/p&gt;

&lt;p&gt;Par contre, le firmware n’est pas forcément disponible dans les cartes réseau communes.&lt;/p&gt;

&lt;p&gt;Ça tombe bien, on peut faire une image compatible PXE pour iPXE (Upsa powered).&lt;/p&gt;

&lt;p&gt;Si on reprend la suite de tout à l’heure :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;PXE télécharge l’image iPXE en TFTP&lt;/li&gt;
  &lt;li&gt;PXE boot l’image iPXE&lt;/li&gt;
  &lt;li&gt;iPXE télécharge le reste de sa configuration en HTTP (ou autre protocole)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Il te faudra donc :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Un serveur DHCP (sur ton routeur/firewall OpenSense)&lt;/li&gt;
  &lt;li&gt;Un serveur TFTP (toujours ton serveur OpenSense)&lt;/li&gt;
  &lt;li&gt;Une image iPXE (sur le serveur TFTP donc OpenSense)&lt;/li&gt;
  &lt;li&gt;Un serveur HTTP (chez OVH ou ton serveur local)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alors, je dis OpenSense, et le reste de l’article est basé dessus. Mais ça fonctionnera parfaitement avec PFSense, DD-WRT, un Linux installé à la “main”.&lt;/p&gt;

&lt;p&gt;Pour générer l’image iPXE, 2 solutions :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://rom-o-matic.eu/&quot;&gt;Un générateur de ROM en ligne&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://git.ipxe.org/ipxe.git&quot;&gt;Compiler à partir des sources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;J’ai passé pas mal de temps a essayer de faire fonctionner les images générées par rom-o-matic. Mais c’était pénible de remettre la configuration, attendre la génération sur le serveur. Et puis, c’est cool de leur libérer un peu de CPU.&lt;/p&gt;

&lt;p&gt;Mais tu peux facilement reproduire la configuration ci-dessous dans les paramètres ROM-o-Matic. Mais c’est beaucoup moins marrant :)&lt;/p&gt;

&lt;p&gt;Bon. On y va ? Ou bien ?&lt;/p&gt;

&lt;h1 id=&quot;installation-du-serveur-ipxe&quot;&gt;Installation du serveur iPXE&lt;/h1&gt;

&lt;p&gt;Tu fais comme tu veux. Mais moi, je mets Nginx comme serveur HTTP. Voici la configuration du virtualhost à mettre :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ipxe.example.com&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;pxe.example.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/ipxe&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.htm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Tu vas maintenant installer tous les fichiers nécessaires à la partie iPXE :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/www
git clone https://github.com/nledez/ipxe-root ipxe
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/www/ipxe
&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'s@%BOOT_URL%@http://ipxe.example.com/@;s@http://boot.smidsrod.lan/@http://ipxe.example.com/@;s@sysrcd-version 3.8.0@sysrcd-version 5.2.2@'&lt;/span&gt; boot.ipxe.cfg.example
&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;boot
&lt;span class=&quot;nb&quot;&gt;touch &lt;/span&gt;boot/.bootdir
./install.sh boot&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;installation-des-sources-pour-linstalleur-ubuntu&quot;&gt;Installation des sources pour l’installeur Ubuntu&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/www/ipxe
./install-ubuntu.sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;généreration-du-binaire-ipxe&quot;&gt;Généreration du binaire iPXE&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /var/www/ipxe
git clone git://git.ipxe.org/ipxe.git ipxe
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;ipxe/src

&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; myscript.ipxe &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
#!ipxe

dhcp
chain http://ipxe.example.com/boot.ipxe
&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF

&lt;/span&gt;vi config/general.h&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;C’est là, ou ça prend du temps pour avoir tous les bons paramètres fonctionnels. Voilà un patch de git vs ma configuration :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-patch&quot; data-lang=&quot;patch&quot;&gt;&lt;span class=&quot;gh&quot;&gt;diff --git a/src/config/general.h b/src/config/general.h
index 3c14a2cd..75f3a432 100644
&lt;/span&gt;&lt;span class=&quot;gd&quot;&gt;--- a/src/config/general.h
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+++ b/src/config/general.h
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@@ -36,16 +36,16 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

 #define	NET_PROTO_IPV4		/* IPv4 protocol */
 #undef	NET_PROTO_IPV6		/* IPv6 protocol */
&lt;span class=&quot;gd&quot;&gt;-#undef	NET_PROTO_FCOE		/* Fibre Channel over Ethernet protocol */
-#define	NET_PROTO_STP		/* Spanning Tree protocol */
-#define	NET_PROTO_LACP		/* Link Aggregation control protocol */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+//#undef	NET_PROTO_FCOE		/* Fibre Channel over Ethernet protocol */
+//#define	NET_PROTO_STP		/* Spanning Tree protocol */
+//#define	NET_PROTO_LACP		/* Link Aggregation control protocol */
&lt;/span&gt;
 /*
  * PXE support
  *
  */
 //#undef	PXE_STACK		/* PXE stack in iPXE - you want this! */
&lt;span class=&quot;gd&quot;&gt;-//#undef	PXE_MENU		/* PXE menu booting */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+#undef	PXE_MENU		/* PXE menu booting */
&lt;/span&gt;
 /*
  * Download protocols
&lt;span class=&quot;p&quot;&gt;@@ -55,9 +55,9 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define	DOWNLOAD_PROTO_TFTP	/* Trivial File Transfer Protocol */
 #define	DOWNLOAD_PROTO_HTTP	/* Hypertext Transfer Protocol */
 #undef	DOWNLOAD_PROTO_HTTPS	/* Secure Hypertext Transfer Protocol */
&lt;span class=&quot;gd&quot;&gt;-#undef	DOWNLOAD_PROTO_FTP	/* File Transfer Protocol */
-#undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */
-#undef	DOWNLOAD_PROTO_NFS	/* Network File System Protocol */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+//#undef	DOWNLOAD_PROTO_FTP	/* File Transfer Protocol */
+//#undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */
+//#undef	DOWNLOAD_PROTO_NFS	/* Network File System Protocol */
&lt;/span&gt; //#undef DOWNLOAD_PROTO_FILE	/* Local filesystem access */

 /*
&lt;span class=&quot;p&quot;&gt;@@ -85,9 +85,9 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * 802.11 cryptosystems and handshaking protocols
  *
  */
&lt;span class=&quot;gd&quot;&gt;-#define	CRYPTO_80211_WEP	/* WEP encryption (deprecated and insecure!) */
-#define	CRYPTO_80211_WPA	/* WPA Personal, authenticating with passphrase */
-#define	CRYPTO_80211_WPA2	/* Add support for stronger WPA cryptography */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+//#define	CRYPTO_80211_WEP	/* WEP encryption (deprecated and insecure!) */
+//#define	CRYPTO_80211_WPA	/* WPA Personal, authenticating with passphrase */
+//#define	CRYPTO_80211_WPA2	/* Add support for stronger WPA cryptography */
&lt;/span&gt;
 /*
  * Name resolution modules
&lt;span class=&quot;p&quot;&gt;@@ -103,16 +103,16 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * you want to use.
  *
  */
&lt;span class=&quot;gd&quot;&gt;-//#define	IMAGE_NBI		/* NBI image support */
-//#define	IMAGE_ELF		/* ELF image support */
-//#define	IMAGE_MULTIBOOT		/* MultiBoot image support */
-//#define	IMAGE_PXE		/* PXE image support */
-//#define	IMAGE_SCRIPT		/* iPXE script image support */
-//#define	IMAGE_BZIMAGE		/* Linux bzImage image support */
-//#define	IMAGE_COMBOOT		/* SYSLINUX COMBOOT image support */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+#define	IMAGE_NBI		/* NBI image support */
+#define	IMAGE_ELF		/* ELF image support */
+#define	IMAGE_MULTIBOOT		/* MultiBoot image support */
+#define	IMAGE_PXE		/* PXE image support */
+#define	IMAGE_SCRIPT		/* iPXE script image support */
+#define	IMAGE_BZIMAGE		/* Linux bzImage image support */
+#define	IMAGE_COMBOOT		/* SYSLINUX COMBOOT image support */
&lt;/span&gt; //#define	IMAGE_EFI		/* EFI image support */
&lt;span class=&quot;gd&quot;&gt;-//#define	IMAGE_SDI		/* SDI image support */
-//#define	IMAGE_PNM		/* PNM image support */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+#define	IMAGE_SDI		/* SDI image support */
+#define	IMAGE_PNM		/* PNM image support */
&lt;/span&gt; #define	IMAGE_PNG		/* PNG image support */
 #define	IMAGE_DER		/* DER image support */
 #define	IMAGE_PEM		/* PEM image support */
&lt;span class=&quot;p&quot;&gt;@@ -136,24 +136,24 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define LOGIN_CMD		/* Login command */
 #define SYNC_CMD		/* Sync command */
 #define SHELL_CMD		/* Shell command */
&lt;span class=&quot;gd&quot;&gt;-//#define NSLOOKUP_CMD		/* DNS resolving command */
-//#define TIME_CMD		/* Time commands */
-//#define DIGEST_CMD		/* Image crypto digest commands */
-//#define LOTEST_CMD		/* Loopback testing commands */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+#define NSLOOKUP_CMD		/* DNS resolving command */
+#define TIME_CMD		/* Time commands */
+#define DIGEST_CMD		/* Image crypto digest commands */
+#define LOTEST_CMD		/* Loopback testing commands */
&lt;/span&gt; //#define VLAN_CMD		/* VLAN commands */
&lt;span class=&quot;gd&quot;&gt;-//#define PXE_CMD		/* PXE commands */
-//#define REBOOT_CMD		/* Reboot command */
-//#define POWEROFF_CMD		/* Power off command */
-//#define IMAGE_TRUST_CMD	/* Image trust management commands */
-//#define PCI_CMD		/* PCI commands */
-//#define PARAM_CMD		/* Form parameter commands */
-//#define NEIGHBOUR_CMD		/* Neighbour management commands */
-//#define PING_CMD		/* Ping command */
-//#define CONSOLE_CMD		/* Console command */
-//#define IPSTAT_CMD		/* IP statistics commands */
-//#define PROFSTAT_CMD		/* Profiling commands */
-//#define NTP_CMD		/* NTP commands */
-//#define CERT_CMD		/* Certificate management commands */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+#define PXE_CMD		/* PXE commands */
+#define REBOOT_CMD		/* Reboot command */
+#define POWEROFF_CMD		/* Power off command */
+#define IMAGE_TRUST_CMD	/* Image trust management commands */
+#define PCI_CMD		/* PCI commands */
+#define PARAM_CMD		/* Form parameter commands */
+#define NEIGHBOUR_CMD		/* Neighbour management commands */
+#define PING_CMD		/* Ping command */
+#define CONSOLE_CMD		/* Console command */
+#define IPSTAT_CMD		/* IP statistics commands */
+#define PROFSTAT_CMD		/* Profiling commands */
+#define NTP_CMD		/* NTP commands */
+#define CERT_CMD		/* Certificate management commands */
&lt;/span&gt;
 /*
  * ROM-specific options
&lt;span class=&quot;p&quot;&gt;@@ -166,14 +166,14 @@&lt;/span&gt; FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * Virtual network devices
  *
  */
&lt;span class=&quot;gd&quot;&gt;-#define VNIC_IPOIB		/* Infiniband IPoIB virtual NICs */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+//#define VNIC_IPOIB		/* Infiniband IPoIB virtual NICs */
&lt;/span&gt; //#define VNIC_XSIGO		/* Infiniband Xsigo virtual NICs */

 /*
  * Error message tables to include
  *
  */
&lt;span class=&quot;gd&quot;&gt;-#undef	ERRMSG_80211		/* All 802.11 error descriptions (~3.3kb) */
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+//#undef	ERRMSG_80211		/* All 802.11 error descriptions (~3.3kb) */
&lt;/span&gt;
 /*
  * Obscure configuration options&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Maintenant, tu vas pouvoir compiler tout ça :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/var/www/ipxe/ipxe/src# make bin/undionly.kpxe
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;VERSION] bin/version.undionly.kpxe.o
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;LD] bin/undionly.kpxe.tmp
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;BIN] bin/undionly.kpxe.bin
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ZINFO] bin/undionly.kpxe.zinfo
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;ZBIN] bin/undionly.kpxe.zbin
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;FINISH] bin/undionly.kpxe
&lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;bin/version.undionly.kpxe.o bin/undionly.kpxe.zinfo bin/undionly.kpxe.bin bin/undionly.kpxe.zbin&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà, c’est terminé pour la partie iPXE.&lt;/p&gt;

&lt;h1 id=&quot;maintenant-tu-dois-configurer-le-dhcp--tftp-sur-lopensense&quot;&gt;Maintenant, tu dois configurer le DHCP / TFTP (sur l’OpenSense)&lt;/h1&gt;

&lt;p&gt;On va commencer par DNSMasq pour la partie TFTP :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/05/dnsmasq-configuration.png&quot; alt=&quot;Configuration de DNSMasq&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Dans Service / Dnsmasq DNS / Settings :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Cocher “Enable” si ce n’est pas fait&lt;/li&gt;
  &lt;li&gt;“Listen port” -&amp;gt; “5353” ou autre chose, mais pas 53 qui rentrerait en conflit avec Unbound&lt;/li&gt;
  &lt;li&gt;“Network interface” -&amp;gt; “LAN”, j’ai mis ça pour éviter de répondre aux requêtes sur la partie WAN&lt;/li&gt;
  &lt;li&gt;“Advanced” voir ci-dessous&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ini&quot; data-lang=&quot;ini&quot;&gt;&lt;span class=&quot;err&quot;&gt;enable-tftp&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;tftp-root&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/tftp&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Clique sur “Save”. Et passes à Unbound :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/05/dhcp-configuration.png&quot; alt=&quot;Configuration du DHCP&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Dans Service / DHCPv4 / LAN :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Dans la partie “TFTP server”
    &lt;ul&gt;
      &lt;li&gt;“Set TFTP hostname” -&amp;gt; “192.168.2.1”&lt;/li&gt;
      &lt;li&gt;“Set Bootfile” -&amp;gt; “/tftp/undionly.kpxe”&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et pour finir, tu vas copier le firmware que tu as construit tout à l’heure. Ouvre un shell (en ssh par exemple):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /tftp
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /tftp/
curl http://ipxe.example.com/ipxe/src/bin/undionly.kpxe &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; undionly.kpxe&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et voilà ce que ça donne :&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://youtu.be/to5nw1eQ7wI&quot;&gt;Screencast de boot iPXE&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tu peux voir le boot PXE + iPXE avec Memtest86+ puis un début d’installation Ubuntu.&lt;/p&gt;
</description>
        <pubDate>Sun, 19 May 2019 00:00:00 -0500</pubDate>
        <link>https://blog.ledez.net/informatique/serveur-ipxe-ou-comment-booter-sans-usb-cd-whatever/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/serveur-ipxe-ou-comment-booter-sans-usb-cd-whatever/</guid>
        
        <category>Informatique</category>
        
        <category>sysadmin</category>
        
        <category>Ubuntu</category>
        
        
        <category>Informatique</category>
        
      </item>
    
      <item>
        <title>ANAVI Light Controller, Sonoff-Tasmota &amp; Domoticz in a boat</title>
        <description>&lt;p&gt;I already have a &lt;a href=&quot;https://domoticz.com/&quot;&gt;Domoticz&lt;/a&gt; install with &lt;a href=&quot;https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch-1.html&quot;&gt;Sonoff&lt;/a&gt; stuff &amp;amp; &lt;a href=&quot;https://github.com/arendst/Sonoff-Tasmota&quot;&gt;Tasmota firmware&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I manage power for:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;My &lt;a href=&quot;https://octoprint.org/&quot;&gt;Octopi&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;My 3d printer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But webcam doesn’t work during the night. I have an &lt;a href=&quot;https://www.crowdsupply.com/anavi-technology/light-controller&quot;&gt;ANAVI Light Controller&lt;/a&gt; to fix this.&lt;/p&gt;

&lt;p&gt;I want this in Domoticz:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/domoticz_use.png&quot; alt=&quot;Use in Domoticz&quot; /&gt;&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;If you want the same, you can do it with this configuration:&lt;/p&gt;

&lt;p&gt;Open “Configuration” / “Configure module” it must look like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/tasmota_config_module.png&quot; alt=&quot;Configure module&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In Domoticz configure a MQTT Gateway, search on the Internet to find out how to do it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/domoticz_mqtt_gateway.png&quot; alt=&quot;MQTT Gateway in Domoticz&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now click on “Create Virtual Sensors”&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/domoticz_create_virtual_sensor.png&quot; alt=&quot;Create Virtual Sensors&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now available in devices view:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/domoticz_create_virtual_sensor.png&quot; alt=&quot;Create Virtual Sensors&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note the “Idx” for later and return to Tasmota configuration “Configure Domoticz” part:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/tasmota_config_domoticz.png&quot; alt=&quot;Configure Domoticz&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Put the “Idx” from Domoticz into “Idx 1”.&lt;/p&gt;

&lt;p&gt;Now you can change state and color in Domoticz:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2019/02/17/domoticz_use.png&quot; alt=&quot;Use in Domoticz&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And voilà!&lt;/p&gt;
</description>
        <pubDate>Sun, 17 Feb 2019 00:00:00 -0600</pubDate>
        <link>https://blog.ledez.net/iot/anavi-light-controller-sonoff-tasmota-domoticz-in-a-boat/</link>
        <guid isPermaLink="true">https://blog.ledez.net/iot/anavi-light-controller-sonoff-tasmota-domoticz-in-a-boat/</guid>
        
        <category>iOT</category>
        
        <category>ESP</category>
        
        <category>Domoticz</category>
        
        
        <category>iOT</category>
        
      </item>
    
      <item>
        <title>Consul 01 - en local</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2018/01/LogoArticlesPC_Terraform_Ansible_Consul_HAProxy.png&quot; alt=&quot;PCi, Terraform, Ansible, Consul &amp;amp; Co.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Pour commencer à jouer un peu avec Consul, on va le faire tourner en local.&lt;/p&gt;

&lt;p&gt;Mais aussi faire un premier tour d’horizon de ses paramètres.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Déjà il faut le binaire à prendre sur le &lt;a href=&quot;https://www.consul.io/downloads.html&quot;&gt;Site de Consul&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ensuite, je t’ai préparé quelques fichiers tout prêts pour t’éviter de tout copier/coller. C’est disponible &lt;a href=&quot;https://github.com/nledez/consul-screencast&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/nledez/consul-screencast.git
cd consul-screencast
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;J’ai aussi mis un script pour se souvenir comment lancer Consul :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cat launch_consul.sh
#!/bin/bash
consul agent -config-dir=$(pwd)/config.d -dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Comme tu dois t’en douter, les fichiers de configuration vont aller dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config.d&lt;/code&gt; :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir config.d
cp ex.consul/* config.d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Voici le contenu de chaque fichier :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;==== config.d/bootstrap.json
{
    &quot;bootstrap&quot;: true
}
==== config.d/server.json
{
    &quot;server&quot;: true,
    &quot;datacenter&quot;: &quot;dc1&quot;,
    &quot;data_dir&quot;: &quot;`(mkdir data &amp;amp;&amp;amp; cd data &amp;amp;&amp;amp; pwd)`&quot;,
    &quot;bind_addr&quot;: &quot;127.0.0.1&quot;,
    &quot;start_join&quot;: [&quot;127.0.0.1&quot;],
    &quot;log_level&quot;: &quot;INFO&quot;
}
==== config.d/ui.json
{
    &quot;ui&quot;: true
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;À la ligne &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_dir&lt;/code&gt;, on va remplacer ce qu’il y a entre les guillemets par le résultat de la commande :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;`(mkdir data &amp;amp;&amp;amp; cd data &amp;amp;&amp;amp; pwd)`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Le paramètre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bootstrap&lt;/code&gt; est à positionner sur un (uniquement un) des serveurs dans le cluster. C’est pour simplifier les élections. Quand les élections n’arrivent pas à se faire (coucou les Belges), celui-là est le dictateur et s’élit de “force”.&lt;/p&gt;

&lt;p&gt;Il y a deux modes pour les services Consul :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Agent&lt;/li&gt;
  &lt;li&gt;Serveur&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Comme on l’a vu plus haut le binaire est lancé avec l’instruction &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;agent&lt;/code&gt;. Mais c’est le paramètre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server&lt;/code&gt; qui va indiquer que cet agent est en mode serveur.&lt;/p&gt;

&lt;p&gt;On pourrait se passer de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;datacenter&lt;/code&gt; qui de toute façon est par défaut à &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dc1&lt;/code&gt;. Mais au moins les choses sont explicites. Consul est prévu pour fonctionner sur plusieurs data-centres. Ce paramètre permet donc de savoir où est situé cet agent.&lt;/p&gt;

&lt;p&gt;On peut aussi démarrer Consul avec le paramètre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-dev&lt;/code&gt;. Dans ce cas toutes les informations seront stockées en mémoire. Donc à chaque redémarrage, on repart à 0.&lt;/p&gt;

&lt;p&gt;Le paramètre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_dir&lt;/code&gt; permet de spécifier où Consul va persister ses informations. Que ce soit pour un serveur ou un agent. Il est impératif de pouvoir faire des lock sur ces fichiers. Il faut donc se méfier des filesystem un peu space type Virtualbox/NFS/… Il est parfaitement logique qu’il faille absolument mettre ce paramètre sur les membres du cluster pour ne pas perdre les données.&lt;/p&gt;

&lt;p&gt;Pour spécifier sur quelle interface réseau Consul va communiquer, on va utiliser &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bind_addr&lt;/code&gt;. Par défaut Consul utilise &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0.0.0&lt;/code&gt;. Mais si plusieurs IPv4 sont présentes sur la machine Consul ne va pas démarrer. Ma machine et certains de mes serveurs ont plusieurs IPv4. Donc autant éviter les problèmes.&lt;/p&gt;

&lt;p&gt;Il faut maintenant spécifier la liste des membres du cluster avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_join&lt;/code&gt;. Ici on va mettre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;127.0.0.1&lt;/code&gt;. C’est juste pour jouer en local.&lt;/p&gt;

&lt;p&gt;Si tu as trop ou pas suffisamment de logs dans ton terminal, tu peux jouer avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;log_level&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Et pour finir le paramètre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ui&lt;/code&gt; indique à Consul de servir l’UI sur le port HTTP.&lt;/p&gt;

&lt;p&gt;Il nous reste qu’à démarrer :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bash ./launch_consul.sh
# Ou :
consul agent -config-dir=$(pwd)/config.d
# Ou encore :
consul agent -config-dir=$(pwd)/config.d -dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ça va te mettre dans la console des trucs du style :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bootstrap = true: do not enable unless necessary
==&amp;gt; Starting Consul agent...
==&amp;gt; Joining cluster...
    Join completed. Synced with 1 initial agents
==&amp;gt; Consul agent running!
           Version: 'v1.0.2'
           Node ID: 'e8b45893-f77f-09b2-3ce5-15397c3a39f6'
         Node name: 'jerry'
        Datacenter: 'dc1' (Segment: '&amp;lt;all&amp;gt;')
            Server: true (Bootstrap: true)
       Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, DNS: 8600)
      Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
           Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false

==&amp;gt; Log data will now stream in as it occurs:

    2018/02/06 22:58:27 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:e8b45893-f77f-09b2-3ce5-15397c3a39f6 Address:127.0.0.1:8300}]
[...]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;En version commentée :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;==&amp;gt; Starting Consul agent... -&amp;gt; Ben là ça démarre...
==&amp;gt; Joining cluster...
    Join completed. Synced with 1 initial agents -&amp;gt; On a joint le cluster. On est synchro avec un agent (c'est lui même)
==&amp;gt; Consul agent running! -&amp;gt; L'agent fonctionne
           Version: 'v1.0.2' -&amp;gt; En version 1.0.2
           Node ID: 'e8b45893-f77f-09b2-3ce5-15397c3a39f6' -&amp;gt; L'ID du noeud
         Node name: 'jerry' -&amp;gt; Son nom
        Datacenter: 'dc1' (Segment: '&amp;lt;all&amp;gt;') -&amp;gt; Il est dans le datacenter 'dc1' et tous les segments
            Server: true (Bootstrap: true) -&amp;gt; C'est un serveur. Et même le dictateur
       Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, DNS: 8600) -&amp;gt; L'agent écoute sur 127.0.0.1
                                                                   -&amp;gt; l'HTTPS est désactivé par défaut
      Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302) -&amp;gt; Ça, c'est pour que les membres du cluster communiquent
           Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false
            -&amp;gt; On ne chiffre pas le protocole Gossip
            -&amp;gt; On ne chiffre ni ne vérifie avec TLS en entrée/sortie
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;On peut aussi vérifier la liste de tous les membres :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ consul members
Node   Address         Status  Type    Build  Protocol  DC   Segment
jerry  127.0.0.1:8301  alive   server  1.0.2  2         dc1  &amp;lt;all&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mais aussi récupérer toutes les informations :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;consul info
agent:
	check_monitors = 0
	check_ttls = 0
	checks = 0
	services = 0
build:
	prerelease =
	revision = b55059f+
	version = 1.0.2
consul:
	bootstrap = true
	known_datacenters = 1
	leader = true
	leader_addr = 127.0.0.1:8300
	server = true
raft:
	applied_index = 181
	[...]
	state = Leader
	term = 2
runtime:
	arch = amd64
	[...]
	version = go1.9.2
serf_lan:
	coordinate_resets = 0
	encrypted = false
	[...]
	query_time = 1
serf_wan:
	coordinate_resets = 0
	encrypted = false
	[...]
	query_time = 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Si tu te connectes sur &lt;a href=&quot;http://127.0.0.1:8500/ui/&quot;&gt;http://127.0.0.1:8500/ui/&lt;/a&gt; tu auras l’IHM de Consul :&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2018/02/consul-01-services.png&quot; alt=&quot;Consul UI liste des services&quot; /&gt;
&lt;img src=&quot;https://blog.ledez.net/images/2018/02/consul-02-nodes.png&quot; alt=&quot;Consul UI liste des noeuds&quot; /&gt;
&lt;img src=&quot;https://blog.ledez.net/images/2018/02/consul-03-kv-empty.png&quot; alt=&quot;Consul UI liste des clés/valeurs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;On va maintenant jouer avec la base de donnée clé/valeur (KV) :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ consul kv put dossier/
Success! Data written to: dossier/
$ consul kv put dossier/value 42
Success! Data written to: dossier/value
$ consul kv get dossier/value
42
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Tu peux vérifier dans l’IHM à chaque étape. Voir si ça bouge. Ou même faire les manipulations dans l’UI.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2018/02/consul-04-with-value.png&quot; alt=&quot;Consul UI avec des clés qui ont des valeurs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Et maintenant un petit peu de ménage :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ consul kv delete dossier/value
Success! Deleted key: dossier/value
$ consul kv delete dossier/
Success! Deleted key: dossier/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Voilà, nous avons déjà vu pas mal de choses avec Consul.&lt;/p&gt;

&lt;p&gt;La screencast qui correspond est disponible sur &lt;a href=&quot;https://youtu.be/gbSQZf_x3DA&quot;&gt;Youtube&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;N’hésitez pas à partager, poser des questions, faire des remarques.&lt;/p&gt;

&lt;p&gt;À bientôt pour la suite.&lt;/p&gt;
</description>
        <pubDate>Wed, 07 Feb 2018 00:00:00 -0600</pubDate>
        <link>https://blog.ledez.net/informatique/devops/consul-01-en-local/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/devops/consul-01-en-local/</guid>
        
        <category>devops</category>
        
        <category>consul</category>
        
        
        <category>DevOps</category>
        
      </item>
    
      <item>
        <title>Ca sert à quoi Consul ?</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://blog.ledez.net/images/2018/01/LogoArticlesPC_Terraform_Ansible_Consul_HAProxy.png&quot; alt=&quot;PCi, Terraform, Ansible, Consul &amp;amp; Co.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/informatique/devops/premiere-partie-terraform-avec-openstack/&quot;&gt;Nicolas me demandait dans un autre billet&lt;/a&gt; :&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Pas l’objet principal de ton article, mais concrètement à quoi ça sert Consul ? Quelle utilisation en as-tu ?&lt;/p&gt;

  &lt;p&gt;Sinon, une raison particulière à utiliser terraform-inventory plutôt que l’inventaire dynamique fournit par OpenStack ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Comme répondre à tout cela ferait un commentaire très long, un article en plus, c’est encore mieux :)&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Consul c’est quoi ? On va s’inspirer de &lt;a href=&quot;https://www.consul.io/intro/index.html&quot;&gt;Introduction to Consul&lt;/a&gt; :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Multicentre de données (datacenter). C’est un outil simplifier la vie des administrateurs système. C’est prévu de base pour fonctionner sur plusieurs datacenters. Les données se répliquent, et en toute logique c’est en cluster. Et ça fonctionne super bien.&lt;/li&gt;
  &lt;li&gt;Une base de donnée clé/valeur. Dans Consul tout est stocké dans la base de données. Chaque valeur y est stockée dans une clé. Il y a une hiérarchie avec des dossiers et tout. Et accessible via une API REST.&lt;/li&gt;
  &lt;li&gt;Service de découverte. Dans ces valeurs, on peut y trouver des inventaires de services. Dans l’exemple que je prendrais plus tard, je veux mettre X serveurs d’application Python. Pour configurer mon Haproxy, je vais aller chercher la liste des serveurs dans Consul.&lt;/li&gt;
  &lt;li&gt;Test de vie. Et justement, pour avoir la liste de mes serveurs d’application Python, je vais installer un agent Consul sur chaque machine et lui ajouter un test de vie. Dés que le serveur est prêt, il en informe consul qui va mettre à jours la configuration haproxy automagiquement. Et pareil quand le serveur sera arrêté.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ça peut servir à plein d’autres choses :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Stocker les configurations de services&lt;/li&gt;
  &lt;li&gt;Stocker les secrets (avec Vault)&lt;/li&gt;
  &lt;li&gt;Monitoring (serveur OK/KO toussa)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ensuite, pourquoi utiliser terraform-inventory ?&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Ça fonctionne automatiquement avec le tfstate&lt;/li&gt;
  &lt;li&gt;Quel que soit le provider (Openstack, autre chose)&lt;/li&gt;
  &lt;li&gt;Je peux avoir autre chose dans mon projet Openstack et je ne veux pas y toucher :p&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Voilà Nicolas. Est-ce que ça répond à tes questions ?&lt;/p&gt;
</description>
        <pubDate>Mon, 29 Jan 2018 00:00:00 -0600</pubDate>
        <link>https://blog.ledez.net/informatique/devops/ca-sert-a-quoi-consul-/</link>
        <guid isPermaLink="true">https://blog.ledez.net/informatique/devops/ca-sert-a-quoi-consul-/</guid>
        
        <category>devops</category>
        
        <category>consul</category>
        
        
        <category>DevOps</category>
        
      </item>
    
  </channel>
</rss>
