sql - Create MySQL Tables with Ansible -


i'm using ansible manage small mail server using ubuntu. wanted use ansible create database can , create users database(s) can also. i'm not sure how create tables using ansible. i'm trying create following 3 mysql tables using ansible:

1)

create table `virtual_domains` (   `id` int(11) not null auto_increment,   `name` varchar(50) not null,   primary key (`id`) ) engine=innodb default charset=utf8; 

2)

create table `virtual_users` (   `id` int(11) not null auto_increment,   `domain_id` int(11) not null,   `password` varchar(106) not null,   `email` varchar(100) not null,   primary key (`id`),   unique key `email` (`email`),   foreign key (domain_id) references virtual_domains(id) on delete cascade ) engine=innodb default charset=utf8; 

3)

create table `virtual_aliases` (   `id` int(11) not null auto_increment,   `domain_id` int(11) not null,   `source` varchar(100) not null,   `destination` varchar(100) not null,   primary key (`id`),   foreign key (domain_id) references virtual_domains(id) on delete cascade ) engine=innodb default charset=utf8; 

i have searched , searched , ask in #ansible , have stated can use mysql_db module complete above task can't find examples give me type of direction on how achieve above in ansible.

any , appreciated!

with mysql_db module can import mysql file. can copy 3 create statements 1 singly text file , import this:

- mysql_db: name=my_db state=import target=/tmp/dump.sql.bz2 

that example taken above linked docs page, there more tasks including 1 shows how copy file host before.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -