Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【メモ】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
You can’t perform that action at this time.