본문 바로가기

728x90
반응형

퍼블릭 클라우드

(232)
C264x200.fwebp.q85 Ansible 인벤토리 설정 Ansible 인벤토리 설정1. Ansible Inventory 기본 경로Ansible은 기본적으로 다음 경로의 인벤토리 파일을 사용한다./etc/ansible/hosts2. 인벤토리 설정vim /etc/ansible/hosts[aweb21]asweb21 ansible_host=10.21.3.54asweb22 ansible_host=10.21.4.199[aweb21:vars]ansible_user=ec2-useransible_port=22ansible_ssh_private_key_file=~/aws-key/keyfile.pem주요 옵션 설명ansible_host: 실제 접속 대상 IP 또는 FQDNansible_user: 접속 사용자ansible_port: SSH 포트 (기본 22)ansible_ssh_..
C264x200.fwebp.q85 [Ansible] MacOS에 Ansible을 설치하기 MacOS에 Ansible을 설치하기 pip로 Ansible 설치 > pip3 install ansible > ansible --version ansible 2.10.9 config file = None configured module search path = ['/Users/sangchul/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.9/site-packages/ansible executable location = /usr/local/bin/ansible python version = 3.9.1 (default, Jan 8 2021,..
C264x200.fwebp.q85 [Terraform] 테라폼 인스턴스(private) 생성 테라폼 인스턴스(private) 생성 메인 모듈 $ vim main.tf #####레디스 서버 module "redisserver" { source = "../../../modules/ec2/instance/private/" prefix = module.vpc.out_prefix suffix = module.vpc.out_suffix env = module.vpc.out_env region = module.vpc.out_region instance_count = 1 name = "redis1" group_name = "redis" #aws_amis = "ami-0742b4e673072066f" instance_type = "t3a.medium" disk_size = "8" key_name = "keype..
C264x200.fwebp.q85 [Terraform] 테라폼 인스턴스(public) 생성 테라폼 인스턴스(public) 생성 메인 모듈 $ vim main.tf #####웹 서버 module "webserver" { source = "../../../modules/ec2/instance/" prefix = module.vpc.out_prefix suffix = module.vpc.out_suffix env = module.vpc.out_env region = module.vpc.out_region instance_count = 2 name = "web1" group_name = "web" #aws_amis = "ami-03ca998611da0fe12" instance_type = "t3a.medium" disk_size = "8" key_name = "keypem" subnet_id = mo..
C264x200.fwebp.q85 [Terraform] 테라폼 리소스 태그 지정(tags) -2 테라폼 리소스 태그 지정(tags) key_pair 편집 - key_pair 모듈 $ vim key_pair.tf ###keypair 생성 resource "aws_key_pair" "this" { count = var.create ? 1 : 0 key_name = var.key_name public_key = var.public_key lifecycle { ignore_changes = [ tags.CreatedDate ] } tags = merge( var.customer_tags, { Name = "${var.suffix}-rds01" } ) } vars.tf 편집 - key_pair 모듈 변수 $ vim vars.tf variable "customer_tags" {} main.tf 편집 - 메인 ..
C264x200.fwebp.q85 [Terraform] 테라폼 리소스 태그 지정(tags) -1 테라폼 리소스 태그 지정(tags) VPC 모듈 vpc.tf 편집 $ vim vpc.tf ###### # locals ###### locals { default_tags = { CreateUser = "terraform" Owner = "sangchul" Project = "blog" Service = "network" } } ###### # VPC ###### resource "aws_vpc" "this" { cidr_block = var.cidr_block enable_dns_hostnames = var.enable_dns_hostnames enable_dns_support = var.enable_dns_support instance_tenancy = var.instance_tenancy lifecy..
C264x200.fwebp.q85 테라폼 vpc peering import(terraform import) 테라폼 vpc peering import(terraform import) vpc peering connection import [버지니아 리전] vpc resources 파일 생성 vim peering.tf #####VPC 페어링 resource "aws_vpc_peering_connection" "vatosg" {} terraform import aws_vpc_peering_connection.vatosg pcx-03c5b $ terraform import aws_vpc_peering_connection.vatosg pcx-03c5b aws_vpc_peering_connection.vatosg: Importing from ID "pcx-03c5b"... aws_vpc_peering_connection...
C264x200.fwebp.q85 [Terraform] 테라폼 output 명령어 테라폼 output 명령어 : terraform 출력 명령은 상태 파일에서 출력 변수의 값을 추출하는데 사용됩니다 VPC 모듈 - output $ vim vpc.tf output "out_prefix" { value = var.prefix } output "out_suffix" { value = var.suffix } output "out_env" { value = var.env } output "out_region" { value = var.aws_region } output "out_aws_vpc_id" { value = aws_vpc.this.id } output "out_aws_vpc_cidr" { value = aws_vpc.this.cidr_block } main 모듈 - output $ vi..

728x90
반응형