LoginSignup
8
7

More than 5 years have passed since last update.

Vagrant上で対話形式のものをinstallする

Posted at

経緯

Vagrantでpeclからインストールするplaybookを書こうと思ったが、対話形式でinstallが行われる箇所があったため、どうしよう...と思った結果、スクリプトを用意して、playbookでスクリプトを/tmpあたりにcopyして実行させました。
その時のメモです。初めてのplaybook!!
(スマートなやり方があれば教えていただきたいです...)

目的

apcのインストールをansibleのtaskとして行うこと

やったこと

対話形式のファイルを用意

install_apc.sh
#!/bin/sh

expect -c "
spawn pecl install apc
expect \"Enable internal debugging in APC \[no\] :\"
send \"no\n\"
expect \"Enable per request file info about files used from the APC cache \[no\] :\"
send \"no\n\"
expect \"Enable spin locks (EXPERIMENTAL) \[no\] :\"
send \"no\n\"
expect \"Enable memory protection (EXPERIMENTAL) \[no\] :\"
send \"no\n\"
expect \"Enable pthread mutexes (default) \[no\] :\"
send \"yes\n\"
expect \"Enable pthread read/write locks (EXPERIMENTAL) \[yes\] :\"
send \"no\n\"
interact
"
exit

apcインストールする前に色々入れておかなきゃいけないもの含めて
taskを用意

main.yaml
- name: install php-pear
  yum: name=php-pear state=installed
- name: install phpize
  yum: name=php-devel state=installed
- name: install apxs
  yum: name=httpd-devel state=installed
- name: install pcre-devel
  yum: name=pcre-devel state=installed
- name: install expect
  yum: name=expect state=installed
- name: copy install apc script
  copy: src=install_apc.sh dest=/tmp owner=root group=root mode=0755
- name : install apc
  sudo: yes
  command: sh /tmp/install_apc.sh
- name: copy apc.ini
  copy: src=apc.ini dest=/etc/php.d/ owner=root group=root mode=0755
- name: mkdir webroot/admin
  shell: mkdir /path/to/webroot
- name: cp apc.php
  shell: cp /usr/share/pear/apc.php /path/to/webroot/

コレで何とか勝手に入ってくれたようです。
yumとかみたいにpeclも勝手に入るコマンドがないかなーとおもって未だ試行錯誤しております。

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7