39 lines
904 B
YAML
39 lines
904 B
YAML
---
|
|
- name: Configure EC2 for ECS Cluster
|
|
hosts: inventory_hosts
|
|
become: yes
|
|
|
|
vars:
|
|
ecs_cluster_name: "nvhi-atsila-cluster"
|
|
|
|
tasks:
|
|
- name: Install Docker
|
|
apt:
|
|
name: docker.io
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Start and enable Docker
|
|
service:
|
|
name: docker
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Write ECS config file
|
|
copy:
|
|
dest: /etc/ecs/ecs.config
|
|
content: |
|
|
ECS_CLUSTER={{ ecs_cluster_name }}
|
|
|
|
- name: Run ECS agent container
|
|
docker_container:
|
|
name: ecs-agent
|
|
image: amazon/amazon-ecs-agent:latest
|
|
state: started
|
|
restart_policy: always
|
|
env_file: /etc/ecs/ecs.config
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- /var/log/ecs:/log
|
|
- /var/lib/ecs/data:/data
|
|
network_mode: host |