Skip to content

Instantly share code, notes, and snippets.

@yusuke2255
Created March 3, 2015 08:46
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 yusuke2255/5a7731b84e42ca3d935e to your computer and use it in GitHub Desktop.
Save yusuke2255/5a7731b84e42ca3d935e to your computer and use it in GitHub Desktop.
【メモ】ansibleでAWSのEC2インスタンスの基本設定をするplaybook ref: http://qiita.com/Kawata/items/d34dda5de93564873ae7
- hosts: '{{host_name}}'
sudo: yes
roles:
- common
- aws/common
- aws/amazon-linux-init
# githubに置いているので本来はここの内容はansible-vault encryptで暗号化されている
# AWSでAPI使う用 (今回のとこでは使ってないけど一応)
access_key_id: ABCDEFGHIJPLMN
secret_access_key: asdfghjfdssa++dfgdfg
ansible-playbook ansible/aws-init-setting.yml -i ansible/inventories/dev/hosts --extra-vars "host_name=dev-common-hoge01" --vault-pass ~/.ansible_dev_vault_pass
# ローカルに実行するためにansible_connectionを設定
local-common-hoge01 ansible_connection=local
local-common-hoge02 ansible_connection=ssh
127.0.0.1 localhost localhost.localdomain {{host_name}}
- name: resolve env
shell: hostname | cut -d "-" -f1
register: env
- name: debug env.stdout
debug: var=env.stdout
- name: read vars file
include_vars: ../vars/dev.yml
when: env.stdout == "local"
- name: read vars file
include_vars: ../vars/dev.yml
when: env.stdout == "dev"
- name: include prod vars file
include_vars: ../vars/prd.yml
when: env.stdout == "prd"
- name: create logs directory
file: path={{app_log_dir}} state=directory owner={{main_user}} group={{main_user}} mode=0755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment