Terraform + Ansible 로 한번에 배포하기

Kevin Park
2 min readFeb 28, 2020

--

Terraform으로 인프라를 만들고 EC2에 Ansible로 프로비저닝 하는 방법 입니다.

시나리오는 아래와 같습니다.

  1. AWS 에 VPC 생성 및 subnet 생성, public, private, security 등
  2. Security Group 생성
  3. SSH Key 생성
  4. Security subnet에 bastion server(EC2) 생성
  5. Public DNS DNS 등록
  6. Private subnet 에 EC2 생성 및 Private DNS 등록
  7. Known Host 처리
  8. Security subnet에 있는 bastion server 를 통해 Private subnet의 EC2에 배포

0. 사전 준비 playbook을 실행할 위치에 ssh.config, ansible.cfg을 만듭니다.(Ansible은 실행 되는 위치의 cfg를 우선으로 합니다)

ssh.config
ansible.cfg
  1. Terraform으로 AWS 에 VPC 생성

2. Security Group 생성

3. SSH Key 생성

4. Security subnet에 bastion server EC2 생성

5. Public DNS DNS 등록

6. Private subnet 에 api server EC2 생성 및 Private DNS 등록

7. Known Host 처리

8. Security subnet에 있는 bastion server 를 통해 Private subnet의 EC2에 배포

사실 config 파일 외에는 별 내용이 없습니다… Ansible 배포가 bastion server를 통해야 되는 경우 참고 해주시면 될 것 같습니다.

terraform apply 시 인프라와 서버 내 프로비저닝 한번에 하고 싶어 해봤습니다.

amazon2 linux에 network command 가 없어 bastion server에 nc 설치가 필요 할 수 있습니다.
amzaon linux 지원 중단 2020.12.31

감사합니다.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Kevin Park
Kevin Park

No responses yet

Write a response