2018年8月28日火曜日

AnsibleでKanboardとMariaDBをインストールする(CentOS7用)

Kanboardは、PHP製のタスク管理ソフトウェアです。

〇Kanboardの管理者画面

ブラウザからhttp://<対象ホスト>/kanboard/にアクセスします。デフォルトユーザ/パスワードはadmin/adminです。

インストール方法

1.下準備
~/.ansible.cfgに以下の内容を設定します
[ssh_connection]
pipelining=True
[defaults]
host_key_checking = False

2. インストール対象ホストのユーザやパスワードを環境に合わせてinventoryファイルに記入します

inventory例
[kanboard]
192.168.1.107

[all:vars]
ansible_ssh_port=22
ansible_ssh_user=vagrant
ansible_ssh_pass=vagrant
ansible_sudo_pass=vagrant

3.inventory、kanboard.ymlを準備し、以下のコマンドを実行します。
ansible-playbook -i inventory kanboard.yml

kanboard.yml
- hosts: kanboard
  vars:
    - dbname: kanboard
    - dbuser: kanboard
    - dbpassword: kanboard
    - dbhost: localhost
    - dbport: 3306
  tasks:
    - name: install mariadb
      yum:
        name: mariadb-server
        state: present
      become: yes
    - name: enable and start mariadb.service
      systemd:
        name: mariadb
        enabled: yes
        state: started
      become: yes
    - name: install epel-release
      yum:
        name: epel-release
        state: present
      become: yes
    - name: Install required software
      yum: name={{ item }} state=present enablerepo=epel
      with_items:
        - mariadb-devel
        - python-devel
        - python36-devel
        - python-pip
      become: true
    - name: install MySQL-python using pip
      pip:
        name: "{{ item }}"
        state: forcereinstall
      with_items:
        - MySQL-python
      become: true
    - name: create db
      mysql_db:
        name={{ dbname }}
        state=present
        encoding=utf8
        login_user=root
    - name: create and grant a database user
      mysql_user:
        name={{ dbuser }}
        password={{ dbpassword }}
        priv="kanboard.*:ALL"
        state=present
      become: true
    - name: install remi repository
      yum: name=http://ftp.riken.jp/Linux/remi/enterprise/remi-release-7.rpm
      become: true
    - name: Install apache and php modules
      yum: name={{ item }} state=present enablerepo=remi-php71
      with_items:
        - httpd
        - php
        - php-mbstring
        - php-gd
        - php-dom
        - php-simplexml
        - unzip
        - php-pdo
        - php-mysql
      become: true
    - name: download kanboard
      get_url:
        url: https://github.com/kanboard/kanboard/archive/v1.2.5.tar.gz
        dest: /tmp/
      become: true
    - name: extract kanboard
      unarchive:
        remote_src: yes
        src: /tmp/kanboard-1.2.5.tar.gz
        dest: /opt/
      become: true
    - name: place skelton
      shell: cp -R  /opt/kanboard-1.2.5/config.default.php /opt/kanboard-1.2.5/config.php
      become: true
    - name: edit config.php
      replace: dest=/opt/kanboard-1.2.5/config.php regexp="define('DB_DRIVER', 'sqlite');" replace="define('DB_DRIVER', 'mysql');"
      become: true
    - name: edit config.php
      replace: dest=/opt/kanboard-1.2.5/config.php regexp="define('DB_USERNAME', 'root');" replace="define('DB_USERNAME', 'kanboard');"
      become: true
    - name: edit config.php
      replace: dest=/opt/kanboard-1.2.5/config.php regexp="define('DB_PASSWORD', '');" replace="define('DB_PASSWORD', 'kanboard');"
      become: true
    - name: change owner
      file:
        path: /opt/kanboard-1.2.5
        owner: apache
        group: apache
        recurse: yes
      become: true
    - name: symlink
      file:
        path: /var/www/html/kanboard
        state: link
        src: /opt/kanboard-1.2.5
      become: true
    - name: clean up
      file:
        state: absent
        path: /tmp/v1.2.5.tar.gz
      become: yes
    - name: start httpd.service
      systemd:
        name: httpd
        state: restarted
      become: yes


関連情報

・Kanboardの設定・操作方法については「Kanboardの設定・操作」を参照してください。

・Kanboardに関する他の記事はこちらを参照してください。

・Kanboardのgithubリポジトリ
https://github.com/kanboard/kanboard

0 件のコメント:

コメントを投稿