automated terminal push
This commit is contained in:
109
ansible/simple-deploy.yml
Normal file
109
ansible/simple-deploy.yml
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
- name: Simple ECS Configuration Test
|
||||
hosts: inventory_hosts
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
vars:
|
||||
ecs_cluster_name: "nvhi-atsila-cluster"
|
||||
|
||||
tasks:
|
||||
- name: Test connectivity
|
||||
ping:
|
||||
tags: [test]
|
||||
|
||||
- name: Check system information
|
||||
debug:
|
||||
msg: |
|
||||
System: {{ ansible_distribution }} {{ ansible_distribution_version }}
|
||||
Hostname: {{ ansible_hostname }}
|
||||
IP: {{ ansible_default_ipv4.address }}
|
||||
tags: [info]
|
||||
|
||||
- name: Update system packages
|
||||
yum:
|
||||
name: '*'
|
||||
state: latest
|
||||
update_cache: yes
|
||||
async: 300
|
||||
poll: 0
|
||||
register: yum_update
|
||||
tags: [packages]
|
||||
|
||||
- name: Wait for package update
|
||||
async_status:
|
||||
jid: "{{ yum_update.ansible_job_id }}"
|
||||
register: update_result
|
||||
until: update_result.finished
|
||||
retries: 30
|
||||
delay: 10
|
||||
tags: [packages]
|
||||
|
||||
- name: Install Docker and ECS components
|
||||
yum:
|
||||
name:
|
||||
- docker
|
||||
- ecs-init
|
||||
- curl
|
||||
- jq
|
||||
state: present
|
||||
tags: [install]
|
||||
|
||||
- name: Start Docker service
|
||||
systemd:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
tags: [services]
|
||||
|
||||
- name: Verify Docker is working
|
||||
command: docker --version
|
||||
register: docker_version
|
||||
changed_when: false
|
||||
tags: [verify]
|
||||
|
||||
- name: Create ECS configuration directory
|
||||
file:
|
||||
path: /etc/ecs
|
||||
state: directory
|
||||
mode: '0755'
|
||||
tags: [config]
|
||||
|
||||
- name: Write ECS configuration
|
||||
copy:
|
||||
dest: /etc/ecs/ecs.config
|
||||
content: |
|
||||
ECS_CLUSTER={{ ecs_cluster_name }}
|
||||
ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]
|
||||
ECS_ENABLE_TASK_IAM_ROLE=true
|
||||
mode: '0644'
|
||||
backup: yes
|
||||
notify: restart ecs
|
||||
tags: [config]
|
||||
|
||||
- name: Start ECS agent
|
||||
systemd:
|
||||
name: ecs
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
tags: [services]
|
||||
|
||||
- name: Display configuration summary
|
||||
debug:
|
||||
msg: |
|
||||
========================================
|
||||
✅ SIMPLE CONFIGURATION COMPLETED
|
||||
========================================
|
||||
Docker Version: {{ docker_version.stdout }}
|
||||
ECS Cluster: {{ ecs_cluster_name }}
|
||||
Instance IP: {{ ansible_default_ipv4.address }}
|
||||
========================================
|
||||
tags: [summary]
|
||||
|
||||
handlers:
|
||||
- name: restart ecs
|
||||
systemd:
|
||||
name: ecs
|
||||
state: restarted
|
||||
daemon_reload: true
|
Reference in New Issue
Block a user