{"id":140,"date":"2013-01-08T15:35:05","date_gmt":"2013-01-08T15:35:05","guid":{"rendered":"http:\/\/www.nicovs.be\/?p=140"},"modified":"2014-01-16T12:41:22","modified_gmt":"2014-01-16T12:41:22","slug":"puppet-add-mysql-user","status":"publish","type":"post","link":"https:\/\/www.nicovs.be\/?p=140","title":{"rendered":"Puppet: Add MySQL User"},"content":{"rendered":"<p>Want to add a user to MySQL that you can use for eg backups, monitoring,&#8230; or any other tasks this user needs to perform. (in this example a root user)<\/p>\n<p>Create a small definition<\/p>\n<pre class=\"lang:default decode:true\">define create_mysqlbckuser (\r\n$mysqlrootpasswd = '',\r\n        )       {\r\n        exec { \"create_mysql_bck\u00b0user\":\r\n        unless =&gt; \"\/usr\/bin\/mysqladmin -ubckuser -p'b4ckupP4ss' status\",\r\n        command =&gt; \"\/usr\/bin\/mysql -uroot -p'$mysqlrootpasswd' -e \\\"GRANT ALL ON *.* TO 'bckuser'@'%' IDENTIFIED BY 'B4ckupP4ss';flush privileges;\\\"\", } }<\/pre>\n<p>This<\/p>\n<p>From your nodes.pp you can call this by:<\/p>\n<pre>create_mysqlbckuser { 'root_user': \r\n        mysqlrootpasswd =&gt; 'B4ckupP4ss, }<\/pre>\n<p>&nbsp;<\/p>\n<p>You can always use the Puppetlabs-mysql module of course!<br \/>\nCheck here: https:\/\/github.com\/puppetlabs\/puppetlabs-mysql<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to add a user to MySQL that you can use for eg backups, monitoring,&#8230; or any other tasks this user needs to perform. (in this example a root user) Create a small definition define create_mysqlbckuser ( $mysqlrootpasswd = &#8221;, ) { exec { &#8220;create_mysql_bck\u00b0user&#8221;: unless =&gt; &#8220;\/usr\/bin\/mysqladmin -ubckuser -p&#8217;b4ckupP4ss&#8217; status&#8221;, command =&gt; &#8220;\/usr\/bin\/mysql -uroot [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3,18],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-mysql","category-puppet"],"_links":{"self":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":9,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nicovs.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}