Akash Jain
Akash Jain

Reputation: 1052

Ansible set root user password

I am newbie in ansible, I need to install mysql in server for that i wrote a playbook

---

- hosts: webservice
  tasks:
  - name: Install MYSQL Server
    apt:  name=mysql-server update_cache=yes state=latest

  - name: Install MYSQL Client
    apt:  name=mysql-client update_cache=yes state=latest

It installed successfully, but I want to write ansible playbook where I mention mysql root password, how can I do it.

Upvotes: 1

Views: 2637

Answers (1)

udondan
udondan

Reputation: 59989

Have you tried the mysql_user module?

- mysql_user: name="root"
              password="your-NEW-password"
              check_implicit_admin=yes
              login_user="root"
              login_password=""
              state=present

With a blank password, not sure what the module expects. If it fails, try to remove the line with login_password.

It requires the MySQLdb Python package on the remote host. For Ubuntu, this command will work: apt-get install python-mysqldb, or as an Ansible task:

- apt: name=python-mysqldb
       state=present

Upvotes: 4

Related Questions