Skip to content

Latest commit

 

History

History

04-db

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Ansible Lab #04 - Database

實習重點

Some Ansible modules have prerequisites

For example,

  • debconf requires the command line debconf tools.

  • mysql_db requires python-mysqldb (for apt) or MySQL-python (for yum).

用到的 module(s)

  • System modules / debconf: Configure a .deb package.

  • Database modules / mysql_db: Add or remove MySQL databases from a remote host.

  • Database modules / mysql_user: Adds or removes a user from a MySQL database.

思考...

Raw SQL statements vs Ansible mysql_* modules.

想接受挑戰嗎?

How to make the debconf step idempotent?

The first time of successful execution, the output is:

TASK: [auto set root password for mysql] **************************************
changed: [default] => (item=mysql-server/root_password)
changed: [default] => (item=mysql-server/root_password_again)

But after that, the output should not be in the "changed" state again. It should be either in the "ok" state:

TASK: [auto set root password for mysql] **************************************
ok: [default]
ok: [default]

or even better, in the "skippping" state:

TASK: [auto set root password for mysql] **************************************
skipping: [default]
skipping: [default]