<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>What a n00b! (ansible)</title><link>https://www.whatan00b.com/</link><description></description><atom:link href="https://www.whatan00b.com/categories/ansible.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sat, 13 Jul 2019 04:41:02 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>MySQL Secure Installation Using Ansible</title><link>https://www.whatan00b.com/posts/mysql-secure-installation-using-ansible/</link><dc:creator>Wyatt</dc:creator><description>&lt;div&gt;&lt;p&gt;Recently I was setting up MySQL using Ansible, and wanted to ensure the mysql_secure_installation script or an equivalent was run to get rid of the default users and db. Turned out that writing a task in Ansible wasn't all that bad using the check_implicit_admin feature of the MySQL plugins, it could even be idempotent.&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;div class="gist"&gt;
&lt;script src="https://gist.github.com/127e3ae7df9a6bf951d787d6cfdd8314.js"&gt;&lt;/script&gt;
&lt;noscript&gt;
&lt;pre&gt;- name: delete anonymous MySQL server user for {{ ansible_nodename }}
  mysql_user: login_user=root
              login_password='{{ mysql_root }}'
              check_implicit_admin=yes
              user=""
              host={{ item }}
              state="absent"
  with_items:
   - ""
   - "{{ ansible_nodename }}"
   - localhost

- name: Change root user password on first run
  mysql_user: login_user=root
              login_password="{{ mysql_root }}"
              check_implicit_admin=yes
              name=root
              password={{ mysql_root }}
              priv=*.*:ALL,GRANT
              host={{ item }}
  with_items:
    - "{{ ansible_nodename }}"
    - 127.0.0.1
    - ::1
    - localhost

- name: remove the MySQL test database
  action: mysql_db login_user=root login_password="{{ mysql_root }}" db=test state=absent&lt;/pre&gt;
&lt;/noscript&gt;
&lt;/div&gt;
&lt;/div&gt;</description><category>ansible</category><category>mysql</category><guid>https://www.whatan00b.com/posts/mysql-secure-installation-using-ansible/</guid><pubDate>Sat, 23 Jan 2016 03:56:28 GMT</pubDate></item></channel></rss>