Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Last active July 21, 2016 02:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kuchitama/6427585 to your computer and use it in GitHub Desktop.
Save Kuchitama/6427585 to your computer and use it in GitHub Desktop.
Sample Playbook to install Nginx from source. Details ->
# 以下のコマンドで本番環境用のサーバ構築が実行されます
ansible-playbook -i hosts nginx.yml --extra-vars="server_name=product worker_processes=2" -k
# 開発環境サーバ構築はこちら
ansible-playbook -i hosts nginx.yml --extra-vars="server_name=product worker_processes=2" -k
#user nobody;
worker_processes {{ worker_processes }};
#pid logs/;
events {
worker_connections 1024;
http {
include mime.types;
default_type application/octet-stream;
log_format main 'remote:$remote_addr\t'
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name {{ server_name }};
location / {
root html;
index index.html index.htm;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
- hosts: test-servers
user: vagrant
sudo: yes
nginx_version: '1.2.8'
nginx_dir: "nginx-{{nginx_version}}"
nginx_url: "{{nginx_dir}}.tar.gz"
install_dir: "/usr/local/nginx"
- name: "install-gcc"
action: yum pkg=gcc state=installed
- name: "get-nginx"
command: wget -O /tmp/$nginx_dir.tar.gz $nginx_url creates=/tmp/$nginx_dir.tar.gz
- name: "expand-nginx"
command: tar xzvf $nginx_dir.tar.gz chdir=/tmp creates=/tmp/$nginx_dir
- name: "configure"
command: ./configure --prefix=$install_dir chdir=/tmp/$nginx_dir
- name: "make"
command: make chdir=/tmp/$nginx_dir
- name: "make-install"
command: make install chdir=/tmp/$nginx_dir
- name: "deploy-nginx.conf"
action: template src=./nginx.conf.j2 dest=$install_dir/conf/nginx.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment