如何通过ansible在debian上安装phpmyadmin?

时间:2014-04-23 10:50:41

标签: phpmyadmin installation debian ansible-playbook

在Debian 7.3上,我已经通过ansible playbook安装了nginx,mysql,php-fpm。

正常情况下,按

安装PHPMyAdmin时
aptitiude install phpmyadmin

需要数据库密码,并进行一些配置。

现在创建一个播放来安装和配置PHPMyAdmin,我该怎么办?

更新

我写过一个用于安装phpmyadmin的游戏。在安装过程中,它需要数据库用户名,密码和自己的帐户。所以在搜索后我发现,有一个名为debconf的ansible模块可以处理该安装过程的一些问题。像这样:

tasks:
- name: debconf for pma
 debconf: name=phpmyadmin question='phpmyadmin/dbconfig-install' value='true' vtype='boolean'

- name: debconf for pma
 debconf: name=phpmyadmin question='phpmyadmin/app-password-confirm' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
 debconf: name=phpmyadmin question='phpmyadmin/mysql/admin-pass' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
 debconf: name=phpmyadmin question='phpmyadmin/mysql/app-pass' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
 debconf: name=phpmyadmin question='phpmyadmin/reconfigure-webserver' value='' vtype='multiselect'

- name: install pma
 apt: pkg=phpmyadmin state=present

- name: configure site
 file: path=/var/www/pma src=/usr/share/phpmyadmin state=link

现在我想了解更多信息?关于安装和配置过程,?

1 个答案:

答案 0 :(得分:6)

谢谢大家。我发现了这个问题。我的问题的一部分是在Mysql安装playbook上,有些是在上面玩。一切都是如此:

的MySQL

tasks:
- name: installing MySQL server on server
  apt: pkg={{item}} update_cache=yes cache_valid_time=86400 state=present
  with_items:
  - python-mysqldb
  - mysql-server

- name: Start mysql service
  service: name=mysql state=started

- name: configuring root user pass and priveliges
  mysql_user: name=root host={{ item }} password={{ mysql_root_pass }} priv=*.*:ALL,GRANT
  with_items:
  - "{{ inventory_hostname }}"
  - 127.0.0.1
  - ::1
  - localhost

- name: copy root configurations file
  template: src=my.cnf dest=/root/.my.cnf owner=root mode=0600

PHPMyAdmin的

tasks:
- name: debconf for pma
  debconf: name=phpmyadmin question='phpmyadmin/dbconfig-install' value='true' vtype='boolean'

- name: debconf for pma
  debconf: name=phpmyadmin question='phpmyadmin/app-password-confirm' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
  debconf: name=phpmyadmin question='phpmyadmin/mysql/admin-pass' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
  debconf: name=phpmyadmin question='phpmyadmin/mysql/app-pass' value='{{mysql_root_pass}}' vtype='password'

- name: debconf for pma
  debconf: name=phpmyadmin question='phpmyadmin/reconfigure-webserver' value='' vtype='multiselect'

- name: install pma
  apt: pkg=phpmyadmin state=present

- name: configure site
  file: path=/var/www/phpmyadmin src=/usr/share/phpmyadmin state=link