Created
March 3, 2015 08:46
-
-
Save yusuke2255/5a7731b84e42ca3d935e to your computer and use it in GitHub Desktop.
【メモ】ansibleでAWSのEC2インスタンスの基本設定をするplaybook ref: http://qiita.com/Kawata/items/d34dda5de93564873ae7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: '{{host_name}}' | |
sudo: yes | |
roles: | |
- common | |
- aws/common | |
- aws/amazon-linux-init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# githubに置いているので本来はここの内容はansible-vault encryptで暗号化されている | |
# AWSでAPI使う用 (今回のとこでは使ってないけど一応) | |
access_key_id: ABCDEFGHIJPLMN | |
secret_access_key: asdfghjfdssa++dfgdfg | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ローカルに実行するためにansible_connectionを設定 | |
local-common-hoge01 ansible_connection=local | |
local-common-hoge02 ansible_connection=ssh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1 localhost localhost.localdomain {{host_name}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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