两个星期以来,我一直在使用Ansible进行MySQL部署和工作。我必须在LV上安装MySQL。
在MySQL部署之前,Ansible脚本会创建/var/lib/mysql
,LV并将其安装在/var/lib/mysql
上。然后,它创建MySQL用户和MySQL组以在MySQL目录上设置0700。完成后,Ansible部署MySQL 5.7。
我的Ansible代码的一部分:
- name: "Group : mysql"
group:
name: "mysql"
state: "present"
tags:
- User mysql
- name: "user : mysql"
user:
name: "mysql"
shell: "mysql"
group: "mysql"
createhome: "no"
append: "True"
state: "present"
tags:
- User
- name: "Set rights on mysql dir "
file:
path: "/var/lib/mysql"
owner: "mysql"
group: "mysql"
mode: 0700
tags:
- mysql dir rights
- name: "mysql root password"
debconf:
name: "mysql-server"
question: "mysql-server/root_password"
value: "{{ password_root_mysql }}"
vtype: "password"
when: password_root_mysql is defined
tags:
- Install
- name: "mysql root password confirmation"
debconf:
name: "mysql-server"
question: "mysql-server/root_password_again"
value: "{{ password_root_mysql }}"
vtype: "password"
when: password_root_mysql is defined
tags:
- Install mysql
- name: "Install : MySQL Server"
apt:
update_cache: "True"
name: "mysql-server"
install_recommends: "True"
tags:
- Install mysql
notify:
- stop mysql
- name: "Copie du template root.cnf.j2 vers root/.my.cnf "
template:
src: "{{ mysql_template_rootcnf }}"
dest: "~/.my.cnf"
owner: "root"
mode: "0600"
tags:
- Install mysql
因此,当我尝试在没有任何LV和目录设置的情况下安装mysql-server
时,它将起作用。但是,当我准备具有良好权限的目录MySQL时,无论是手动部署还是自动部署,安装都无法进行。
有什么想法吗?
Ubuntu 16.04和MYSQL 5.7。 Ansible v2.7
答案 0 :(得分:0)
好吧,我发现了问题,/ var / lib / mysql(在lv挂载在其中)的Lost + Found目录被认为像数据库一样,mysql不喜欢它。在我的代码中,我刚刚添加了
- name: "Remove lost+found from {{ mysql_dir }}"
file:
path: "{{ mysql_dir }}/lost+found"
state: absent