{"id":51,"date":"2018-12-18T14:09:04","date_gmt":"2018-12-18T13:09:04","guid":{"rendered":"http:\/\/blog.nosland.com\/?p=51"},"modified":"2018-12-18T14:10:56","modified_gmt":"2018-12-18T13:10:56","slug":"saltstack","status":"publish","type":"post","link":"http:\/\/blog.nosland.com\/?p=51","title":{"rendered":"SALTSTACK"},"content":{"rendered":"\n<h3 style=\"text-align:left\">1&nbsp;SALTSTACK<\/h3>\n\n\n\n<p>Quand on administre plusieurs serveurs, il y a des t\u00e2ches qu\u2019on effectue sur chacun d\u2019eux de mani\u00e8re r\u00e9p\u00e9t\u00e9es.<\/p>\n\n\n\n<p>Quand on a 2 ou 3 serveurs, \u00e7a va, mais quand on g\u00e8re 10, 100 ou 1000 serveurs, la t\u00e2che est impossible.<\/p>\n\n\n\n<p>Saltstack (ou salt) est un gestionnaire de configuration, de provisionning, de commande \u00e0 distance et de d\u00e9ploiement de fichiers.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/cv.geniaut.fr\/Paris8\/wikiP8\/webdsi.univ-paris8.fr\/site\/Systeme\/Salt\/Images\/salt.png\" alt=\"PIC\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/saltstack.com\n<\/div><\/figure>\n\n\n\n<p>L\u2019outils fonctionne sur le principe du client\/serveur, avec une machine&nbsp;<strong>master<\/strong>&nbsp;qui dispose de toutes les configurations et les d\u00e9ploie vers les clients, qui sont appel\u00e9s&nbsp;<strong>minions<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/cv.geniaut.fr\/Paris8\/wikiP8\/webdsi.univ-paris8.fr\/site\/Systeme\/Salt\/Images\/fonctionnement.png\" alt=\"PIC\"\/><\/figure>\n\n\n\n<p>Les minions peuvent utiliser fonctionner sur plusieurs syst\u00e8mes d\u2019exploitation&nbsp;: debian, RedHat, et m\u00eame Windows.<\/p>\n\n\n\n<p>Les minions et le master s\u2019identifient par cl\u00e9 priv\u00e9e, communiquent via ZeroMQ et \u00e9change des informations chiffr\u00e9es en AES.<\/p>\n\n\n\n<p>Il est \u00e9galement possible d\u2019avoir plusieurs Masters ou d\u2019utiliser salt-minion sans aucun master.<\/p>\n\n\n\n<h4>1.1&nbsp;PRINCIPE DE FONCTIONNEMENT<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/cv.geniaut.fr\/Paris8\/wikiP8\/webdsi.univ-paris8.fr\/site\/Systeme\/Salt\/Images\/commandes.png\" alt=\"PIC\"\/><\/figure>\n\n\n\n<p>Le principe est simple&nbsp;:<\/p>\n\n\n\n<p>le master envoie des commandes aux minions qui lui retournent les r\u00e9sultats de ces commandes<\/p>\n\n\n\n<p>Le sch\u00e9ma suivant pr\u00e9sente plus en d\u00e9tails le mode de communication entre un master et son minion.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\/\/cv.geniaut.fr\/Paris8\/wikiP8\/webdsi.univ-paris8.fr\/site\/Systeme\/Salt\/Images\/fonctionnement2.png\" alt=\"PIC\"\/><\/figure>\n\n\n\n<h3>2&nbsp;INSTALLATION<\/h3>\n\n\n\n<h4>2.1&nbsp;SERVEUR (MASTER)<\/h4>\n\n\n\n<p>Travailler sur Debian 8, on va utiliser le paquet g\u00e9n\u00e9r\u00e9 et maintenu par Salt.<\/p>\n\n\n\n<p>On commence par ajouter la cl\u00e9 du serveur de d\u00e9p\u00f4t&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\"><em>#&nbsp;wget&nbsp;\u2212O&nbsp;\u2212&nbsp;http:\/\/repo.saltstack.com\/apt\/debian\/8\/amd64\/latest\/SALTSTACK\u2212GPG\u2212KEY.pub&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;apt\u2212key&nbsp;add&nbsp;\u2212&nbsp;<br>#&nbsp;echo&nbsp;\u00ab\u00a0deb&nbsp;http:\/\/repo.saltstack.com\/apt\/debian\/latest&nbsp;jessie&nbsp;main\u00a0\u00bb&nbsp;&gt;&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/etc\/apt\/sources.list.d\/saltstack.list<\/em><\/p>\n\n\n\n<p>On peut ensuite passer \u00e0 la phase d\u2019installation du master&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\"><em>#&nbsp;apt\u2212get&nbsp;update&nbsp;;&nbsp;apt\u2212get&nbsp;install&nbsp;salt\u2212master<\/em><\/p>\n\n\n\n<p>Quelques commandes utiles&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\"><em>#&nbsp;salt\u2212key&nbsp;\u2212L&nbsp;#&nbsp;liste&nbsp;les&nbsp;cles&nbsp;<br>#&nbsp;salt\u2212key&nbsp;\u2212a&nbsp;minion1&nbsp;#&nbsp;accepte&nbsp;minion1&nbsp;<br>#&nbsp;salt&nbsp;\u2019\u2217\u2019&nbsp;test.ping&nbsp;#&nbsp;on&nbsp;verifie&nbsp;que&nbsp;nos&nbsp;minions&nbsp;repondent&nbsp;<br>#&nbsp;salt&nbsp;\u2019\u2217\u2019&nbsp;cmd.run&nbsp;\u2018uname&nbsp;\u2212a\u2018&nbsp;#&nbsp;lancer&nbsp;une&nbsp;commande&nbsp;sur&nbsp;tous&nbsp;les&nbsp;minions&nbsp;<br>#&nbsp;salt&nbsp;\u2019\u2217\u2019&nbsp;cmd.run&nbsp;\u2018echo&nbsp;\u00ab\u00a0Le&nbsp;master&nbsp;me&nbsp;controle&nbsp;!\u00a0\u00bb\u2018&nbsp;<br>#&nbsp;salt&nbsp;minion1&nbsp;network.ipaddr&nbsp;eth0&nbsp;#&nbsp;donne&nbsp;l\u2019IP&nbsp;d\u2019eth0<\/em><\/p>\n\n\n\n<h4>2.2&nbsp;CLIENT (MINION)<\/h4>\n\n\n\n<p>Tout comme pour le serveur, on commence par ajouter la cl\u00e9 du serveur de d\u00e9p\u00f4t&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;wget&nbsp;\u2212O&nbsp;\u2212&nbsp;http:\/\/repo.saltstack.com\/apt\/debian\/8\/amd64\/latest\/SALTSTACK\u2212GPG\u2212KEY.pub&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;apt\u2212key&nbsp;add&nbsp;\u2212&nbsp;<br>#&nbsp;echo&nbsp;\u00ab\u00a0deb&nbsp;http:\/\/repo.saltstack.com\/apt\/debian\/latest&nbsp;jessie&nbsp;main\u00a0\u00bb&nbsp;&gt;&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/etc\/apt\/sources.list.d\/saltstack.list<\/p>\n\n\n\n<p>On passe \u00e0 l\u2019installation&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;apt\u2212get&nbsp;install&nbsp;salt\u2212minion&nbsp;<br>#&nbsp;apt\u2212get&nbsp;install&nbsp;salt\u2212ssh&nbsp;<br>#&nbsp;systemctl&nbsp;restart&nbsp;salt\u2212minion<\/p>\n\n\n\n<p>On modifie l\u2019identifiant du serveur client dans<strong><em> \/etc\/salt\/minion_id<\/em><\/strong><\/p>\n\n\n\n<p>Dans le cas pr\u00e9sent&nbsp;: myserver.nosland.com<\/p>\n\n\n\n<p>On peut ensuite red\u00e9marrer le minion&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;systemctl&nbsp;restart&nbsp;salt\u2212minion<\/p>\n\n\n\n<h5>2.2.1&nbsp;MODIFICATION SUR LE SERVEUR<\/h5>\n\n\n\n<p>En listant les cl\u00e9s, on voit que le minion <em><strong>myserver.nosland.com<\/strong><\/em> est en mode \u201cunaccepted\u201d&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;salt\u2212key&nbsp;\u2212L&nbsp;<br>Accepted&nbsp;Keys:&nbsp;<br>salt\u2212minion.nosland.com&nbsp;<br>salt.nosland.com&nbsp;<br>Denied&nbsp;Keys:&nbsp;<br>(none)&nbsp;<br>Unaccepted&nbsp;Keys:&nbsp;<br>myserver.nosland.com&nbsp;<br>Rejected&nbsp;Keys:&nbsp;<br>(none)&nbsp;<br>#&nbsp;salt\u2212key&nbsp;\u2212a&nbsp;myserver.nosland.com<\/p>\n\n\n\n<p>La derni\u00e8re commande permet d\u2019accepter le minion.<\/p>\n\n\n\n<p>On peut passer \u00e0 la phase de configuration des services.<\/p>\n\n\n\n<h3>3&nbsp;CONFIGURATION ET UTILISATION<\/h3>\n\n\n\n<p>Le but recherch\u00e9 est de d\u00e9ployer une configuration minimale sur des serveurs afin de leur garantir un m\u00eame \u00e9tat et une certaine coh\u00e9rence&nbsp;:<\/p>\n\n\n\n<ul><li>m\u00eame version de paquets<\/li><li>m\u00eame fichier de configuration<\/li><li>m\u00eame utilisateurs admin<\/li><\/ul>\n\n\n\n<p>Pour cela, nous allons utiliser des&nbsp;<strong>States<\/strong>.<\/p>\n\n\n\n<p>Il s\u2019agit de fichier texte en YAML (Yes Another Markup Language&nbsp;!&nbsp;!) assez simple \u00e0 lire et \u00e0 comprendre o\u00f9 on d\u00e9crit l\u2019\u00e9tat voulu pour notre serveur.<\/p>\n\n\n\n<p>Le placement de ces fichiers doit \u00eatre structur\u00e9 afin de garantir une certaine coh\u00e9rence.<\/p>\n\n\n\n<p>Ces states, de base, se trouvent dans <strong><em>\/srv\/salt<\/em><\/strong>.<\/p>\n\n\n\n<p>Le fichier <strong><em>top.sls<\/em><\/strong> r\u00e9f\u00e9rence l\u2019ensemble des configurations disponibles&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">base:&nbsp;<br>&nbsp;&nbsp;\u2019myserver.nosland.com\u2019:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;apache2<\/p>\n\n\n\n<p>Dans le cas pr\u00e9sent, on d\u00e9clare un service apache2 utilisable par le minion myserver.nosland.com.<\/p>\n\n\n\n<h4>3.1&nbsp;INSTALLATION D\u2019UN PACKAGE<\/h4>\n\n\n\n<p>On souhaite installer le paquet <em>apache2<\/em> sur myserver.nosland.com.<\/p>\n\n\n\n<p>On cr\u00e9e le dossier <em><strong>\/srv\/salt\/apache2<\/strong><\/em> et le fichier <strong><em>\/srv\/salt\/apache2\/init.sls&nbsp;:<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">apache2:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;ID&nbsp;declaration&nbsp;<br>&nbsp;&nbsp;pkg:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;state&nbsp;declaration&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;installed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;function&nbsp;declaration<\/p>\n\n\n\n<p>Pour r\u00e9aliser l\u2019installation sur le minion, il suffit ensuite d\u2019ex\u00e9cuter la commande&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;salt&nbsp;myserver.nosland.com state.apply<\/p>\n\n\n\n<p>On peut v\u00e9rifier l\u2019installation d\u2019apache2 sur myserver.nosland.com.<\/p>\n\n\n\n<h4>3.2&nbsp;AUTO DEMARRAGE D\u2019UN SERVICE<\/h4>\n\n\n\n<p>Le paquet apache2 est install\u00e9 sur le minion, mais il n\u2019est pas lanc\u00e9&nbsp;!<\/p>\n\n\n\n<p>Pour cela, on modifie le fichier <strong><em>\/srv\/salt\/apache2\/init.sls&nbsp;:<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">apache2:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;ID&nbsp;declaration&nbsp;<br>&nbsp;&nbsp;pkg.installed:&nbsp;[]&nbsp;<br>&nbsp;&nbsp;service.running:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;require:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;pkg:&nbsp;apache2<\/p>\n\n\n\n<p>Pour r\u00e9aliser la configuration sur le minion, il suffit ensuite d\u2019ex\u00e9cuter la commande&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;salt&nbsp;myserver.nosland.com state.apply<\/p>\n\n\n\n<h4>3.3&nbsp;PERSONNALISATION D\u2019UN PAQUET<\/h4>\n\n\n\n<p>Notre service apache2 fonctionne.<\/p>\n\n\n\n<p>On souhaite modifier la page par d\u00e9faut <strong><em>\/var\/www\/html\/index.html&nbsp;:<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">&lt;html&gt;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;en&nbsp;construction&#8230;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/body&gt;&nbsp;<br>&lt;\/html&gt;<\/p>\n\n\n\n<p>On place ce fichier dans le dossier <strong><em>\/srv\/salt\/apache2\/files\/<\/em><\/strong><\/p>\n\n\n\n<p>On modifie ensuite le fichier <strong><em>\/srv\/salt\/apache2\/init.sls&nbsp;:<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">apache2:&nbsp;<br>&nbsp;&nbsp;pkg.installed:&nbsp;[]&nbsp;<br>&nbsp;&nbsp;service.running:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;require:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;pkg:&nbsp;apache2&nbsp;<br><br>\/var\/www\/html\/index.html:&nbsp;<br>&nbsp;&nbsp;file:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;state&nbsp;declaration&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;managed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;function&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;source:&nbsp;salt:\/\/apache2\/files\/index.html&nbsp;&nbsp;&nbsp;#&nbsp;function&nbsp;arg&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;require:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;requisite&nbsp;declaration&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;pkg:&nbsp;apache2<\/p>\n\n\n\n<p>Pour r\u00e9aliser la configuration sur le minion, il suffit ensuite d\u2019ex\u00e9cuter la commande&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;salt&nbsp;myserver.nosland.com state.apply<\/p>\n\n\n\n<h3>4&nbsp;PILLAR<\/h3>\n\n\n\n<p>Les pillar permettent de placer des configurations sp\u00e9cifiques sur des minions.<\/p>\n\n\n\n<p>Le dossier de configuration se trouve dans <strong><em>\/srv\/pillar<\/em><\/strong>, et le fichier de base est <strong><em>\/srv\/pillar\/top.sls<\/em><\/strong><\/p>\n\n\n\n<h4>4.1&nbsp;UTILISATEURS<\/h4>\n\n\n\n<p>Les utilisateurs \u00e0 configurer sur les minions se placent dans <strong><em>\/srv\/pillar\/users<\/em><\/strong>.<\/p>\n\n\n\n<p>Dans l\u2019exemple suivant <strong><em>\/srv\/pillar\/users\/nospheratus.sls<\/em><\/strong>, on d\u00e9clare toutes les informations personnelles de l\u2019utilisateur nospheratus:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">&nbsp;&nbsp;users:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;nospheratus:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fullname:&nbsp;NosPHeratus NPH&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password:&nbsp;$6$htudop$JtgUjOFuioHHJsdtkeazdlOjkj..AXH4iKjOO\/&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;home:&nbsp;\/home\/nospheratus&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sudouser:&nbsp;True&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sudo_rules:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;ALL=(ALL)&nbsp;ALL&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell:&nbsp;\/bin\/bash&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;groups:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;adm&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;sudo&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ssh_key_type:&nbsp;rsa&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ssh_auth:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;ssh\u2212rsa&nbsp;AAAAC5GhuR2pl2FAAAAEAFACAAARASD3YlAiCGah48lXWbotiq6FZQZdE6FdqXec4oVrKH4Y&nbsp; &nbsp; &nbsp; yeXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXD5ytDZkAfX9&nbsp;nospheratus@nosland<\/p>\n\n\n\n<p>Pour r\u00e9aliser la configuration sur le minion, il suffit ensuite d\u2019ex\u00e9cuter la commande&nbsp;:#&nbsp;salt&nbsp;myserver.nosland.com state.apply<\/p>\n\n\n\n<h3>5&nbsp;EXEMPLES DE STATES<\/h3>\n\n\n\n<h4>5.1&nbsp;WORDPRESS<\/h4>\n\n\n\n<p>Le state wordpress a pour but de pouvoir installer et configurer le gestionnaire de contenu Web automatiquement sur un minion.<\/p>\n\n\n\n<p>Dans le dossier de configuration de Salt <em><strong>\/src\/salt<\/strong><\/em>, on y place le state <strong><em>wordpress\/init.sls&nbsp;:<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-color has-background has-luminous-vivid-amber-color has-very-dark-gray-background-color\">#&nbsp;Creation&nbsp;de&nbsp;l\u2019utilisateur&nbsp;local&nbsp;wordpress&nbsp;<br>wordpress:&nbsp;<br>&nbsp;&nbsp;user.present:&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;fullname:&nbsp;Utilisateur&nbsp;pour&nbsp;Wordpress&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;home:&nbsp;\/home\/wordpress&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;shell:&nbsp;\/bin\/bash&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212&nbsp;password:&nbsp;None&nbsp;<br><br>#&nbsp;Creation&nbsp;de&nbsp;la&nbsp;base&nbsp;de&nbsp;donnees&nbsp;<br>wordpress_db:&nbsp;<br>&nbsp;mysql_user.present:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;wordpress&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;password:&nbsp;{{&nbsp;pillar[\u2019SQL_WORDPRESS_PASSWORD\u2019]&nbsp;}}&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_user:&nbsp;root&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_pass:&nbsp;{{&nbsp;pillar[\u2019SQL_ROOT_PASSWORD\u2019]&nbsp;}}&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_charset:&nbsp;utf8&nbsp;<br>&nbsp;mysql_database.present:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;wordpress&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_user:&nbsp;root&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_pass:&nbsp;{{&nbsp;pillar[\u2019SQL_ROOT_PASSWORD\u2019]&nbsp;}}&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_charset:&nbsp;utf8&nbsp;<br>&nbsp;mysql_grants.present:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;database:&nbsp;wordpress.\u2217&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;grant:&nbsp;ALL&nbsp;PRIVILEGES&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;user:&nbsp;wordpress&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;host:&nbsp;\u2019%\u2019&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_user:&nbsp;root&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_pass:&nbsp;{{&nbsp;pillar[\u2019SQL_ROOT_PASSWORD\u2019]&nbsp;}}&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;connection_charset:&nbsp;utf8&nbsp;<br><br>#&nbsp;Archive&nbsp;eventuelle&nbsp;de&nbsp;l\u2019ancienne&nbsp;version&nbsp;de&nbsp;WP&nbsp;<br>archive_wordpress:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019mv&nbsp;{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}&nbsp;{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}_\u2018date&nbsp;+%F\u2018\u2019&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/var\/www\/html\/&nbsp;<br><br>#&nbsp;Telechargement&nbsp;de&nbsp;la&nbsp;derniere&nbsp;version&nbsp;de&nbsp;wordpress&nbsp;<br>get_wordpress:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019wget&nbsp;http:\/\/wordpress.org\/latest.tar.gz&nbsp;&amp;&amp;&nbsp;tar&nbsp;xvzf&nbsp;latest.tar.gz&nbsp;&amp;&amp;&nbsp;rm&nbsp;latest.tar.gz&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;&amp;&nbsp;mv&nbsp;wordpress&nbsp;&nbsp;{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\u2019&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/var\/www\/html\/&nbsp;<br><br>#&nbsp;Installation&nbsp;de&nbsp;WP\u2212Cli&nbsp;<br>get_wp\u2212cli:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019curl&nbsp;\u2212O&nbsp;https:\/\/raw.githubusercontent.com\/wp\u2212cli\/builds\/gh\u2212pages\/phar\/wp\u2212cli.phar&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;&amp;&nbsp;chmod&nbsp;+x&nbsp;wp\u2212cli.phar\u2019&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/home\/wordpress\/&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;user:&nbsp;wordpress&nbsp;<br><br>#&nbsp;Ajout&nbsp;du&nbsp;lien&nbsp;symbolique&nbsp;dans&nbsp;le&nbsp;PATH&nbsp;par&nbsp;defaut&nbsp;<br>\/usr\/local\/bin\/wp:&nbsp;<br>&nbsp;file:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;symlink&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;target:&nbsp;\/home\/wordpress\/wp\u2212cli.phar&nbsp;<br><br>#&nbsp;Creation&nbsp;du&nbsp;fichier&nbsp;de&nbsp;configuration&nbsp;wp\u2212config.php&nbsp;<br>config_wordpress:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/var\/www\/html\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\/&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019\/usr\/local\/bin\/wp&nbsp;core&nbsp;config&nbsp;\u2212\u2212dbname=wordpress&nbsp;\u2212\u2212dbuser=wordpress&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212dbpass={{&nbsp;pillar[\u2019SQL_WORDPRESS_PASSWORD\u2019]&nbsp;}}&nbsp;\u2212\u2212allow\u2212root&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212path=\/var\/www\/html\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\u2019&nbsp;<br><br>#&nbsp;Installation&nbsp;de&nbsp;wordpress&nbsp;<br>install_wordpress:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/var\/www\/html\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\/&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019\/usr\/local\/bin\/wp&nbsp;core&nbsp;install&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212url=http:\/\/{{&nbsp;pillar[\u2019SITE_SERVEUR\u2019]&nbsp;}}\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212title=\u00a0\u00bb{{&nbsp;pillar[\u2019SITE_TITRE\u2019]&nbsp;}}\u00a0\u00bb&nbsp;\u2212\u2212admin_user=admin&nbsp;\u2212\u2212admin_password=password&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212admin_email={{&nbsp;pillar[\u2019SITE_WEBMASTER\u2019]&nbsp;}}&nbsp;\u2212\u2212allow\u2212root&nbsp;\\&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2212\u2212path=\/var\/www\/html\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\u2019&nbsp;<br><br>#&nbsp;Ajout&nbsp;de&nbsp;parametres&nbsp;a&nbsp;la&nbsp;config&nbsp;<br>config_wordpress_add:&nbsp;<br>&nbsp;cmd.run:&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;cwd:&nbsp;\/var\/www\/html\/{{&nbsp;pillar[\u2019SITE_NAME\u2019]&nbsp;}}\/&nbsp;<br>&nbsp;&nbsp;\u2212&nbsp;name:&nbsp;\u2019echo&nbsp;\u00ab\u00a0define(\u2019\u2019WP_SITEURL\u2019\u2019,\u2019\u2019{{&nbsp;pillar[\u2019SITE_URL\u2019]&nbsp;}}\u2019\u2019);\u00a0\u00bb&nbsp;&gt;&gt;&nbsp;wp\u2212config.php\u2019<\/p>\n\n\n\n<p>Plusieurs param\u00e8tres sont \u00e0 renseigner dans un pillar&nbsp;:<\/p>\n\n\n\n<p class=\"has-text-color has-background has-vivid-red-color has-light-green-cyan-background-color\">SQL_ROOT_PASSWORD:&nbsp;mot&nbsp;de&nbsp;passe&nbsp;root&nbsp;de&nbsp;mysql&nbsp;<br>SQL_WORDPRESS_PASSWORD:&nbsp;mot&nbsp;de&nbsp;passe&nbsp;de&nbsp;l\u2019utilisateur&nbsp;WP&nbsp;<br>SITE_NAME:&nbsp;nom\/URI&nbsp;du&nbsp;site&nbsp;web&nbsp;<br>SITE_WEBMASTER:&nbsp;adresse&nbsp;de&nbsp;courriel&nbsp;du&nbsp;webmaster&nbsp;<br>SITE_TITRE:&nbsp;titre&nbsp;du&nbsp;site&nbsp;WP&nbsp;<br>SITE_SERVEUR:&nbsp;adresse&nbsp;IP\/nom&nbsp;du&nbsp;serveur&nbsp;WP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1&nbsp;SALTSTACK Quand on administre plusieurs serveurs, il y a des t\u00e2ches qu\u2019on effectue sur chacun d\u2019eux de mani\u00e8re r\u00e9p\u00e9t\u00e9es. Quand&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/posts\/51"}],"collection":[{"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=51"}],"version-history":[{"count":5,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":56,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions\/56"}],"wp:attachment":[{"href":"http:\/\/blog.nosland.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.nosland.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}