In case you weren't aware, there is a pretty full featured mysql role on Ansible Galaxy. That may give you some hints.
https://galaxy.ansible.com/list#/roles/1 - James On Tuesday, April 1, 2014 11:49:36 AM UTC-4, Patrick Ogenstad wrote: > > I've just gotten started with Ansible. I must say it's ridiculously > simple. :) > > I've created a few playbooks and was setting up mysql. The module > documentation mentions editing ~/.my.cnf and some links on the net > recommend using the file in order to create a idempotent mysql playbook. > > However I didn't want to write the password in a textfile. > > Instead as a workaround I created two tasks in the playbook: > > # This task will fail the first time when the password > # is blank > - name: Ensure MySQL Root Password is changed, this task will fail the > first time > mysql_user: name=root password={{ mysqlrootpass }} login_user=root > login_password={{ mysqlrootpass }} state=present > register: mysqlwithpassword > ignore_errors: True > > - name: Set MySQL root password > mysql_user: name=root password={{ mysqlrootpass }} login_user=root > login_password='' state=present > when: mysqlwithpassword|failed > > The first task will always fail on the first run and when it fail the > second task will run. Running the Playbook a second time won't change the > system making the playbook idempotent. > > Would this be considered bad form in a Ansible sort of way? :) Do you see > any downside to solving the problem in this way? > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2636b30c-1867-4e3f-88bc-944a7d7ad91b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
