Skip to content

Instantly share code, notes, and snippets.

@adwinying
Created December 17, 2018 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adwinying/30cb07935da19e1264dca5f1ead798e6 to your computer and use it in GitHub Desktop.
Save adwinying/30cb07935da19e1264dca5f1ead798e6 to your computer and use it in GitHub Desktop.
2. シェルスクリプトを移植
---
- hosts: all
become: yes
become_user: root
vars:
DB_ROOT_PASS='root'
DB_USER='user'
DB_PASS='pass'
DB_NAME='db'
tasks:
- name: 'apt-getを更新'
shell: apt-get update
- name: 'apacheをインストール'
shell: apt-get install -y apache2
- name: 'postgresqlリポを追加'
shell: add-apt-repository ppa:ondrej/php
- name: 'aptを更新'
shell: apt update
- name: 'phpをインストール
shell: apt install -y php5.6 php5.6-pgsql php5.6-mbstring php5.6-gd libapache2-mod-php5.6 libapache2-mpm-itk
- name: 'phpを有効'
shell: a2enmod php5.6
- name: 'postgresql apt-keyを追加
shell: wget -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
- name: 'postgres リポを追加
shell: echo deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main | tee /etc/apt/sources.list.d/postgresql.list
- name: 'apt-getを更新'
shell: apt-get update
- name: 'phpをインストール
shell: apt-get install -y postgresql-9.2 postgresql-contrib-9.2
- name: 'DBユーザーを生成'
shell: sudo -u postgres psql -c "CREATE USER ${DB_USER} WITH SUPERUSER CREATEDB ENCRYPTED PASSWORD '${DB_PASS}'"
- name: 'DBを生成'
shell: sudo -u postgres createdb ${DB_NAME}
- name: 'DB dumpファイルをインポート'
shell: sudo -u postgres psql -f db.dump -d ${DB_NAME}
- name: '既存のwwwディレクトリを削除'
shell: rm -rf /var/www
- name: 'symlinkを生成'
shell: ln -fs /vagrant /var/www
- name: 'apacheサービスを再起動'
shell: service apache2 restart
- name: 'postgresqlサービスを再起動'
shell: service postgresql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment