From 0a3bf279dff2b7b2690213cf2ca7bfbbbea4c103 Mon Sep 17 00:00:00 2001 From: Amaury Souza Date: Tue, 21 Jan 2020 11:24:44 -0300 Subject: [PATCH 1/2] Update README.md New controbuition for your repo. I edited your readme.md page where you demonstrate playbooks Ansible. If you need any question, please, contact me. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 30db2e5..62b3cc9 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,24 @@ A playbook is the gathering between hosts where will be applied tasks. state: installed ``` +**Update systems using Ansible playbook** +``` +--- +- hosts: local + tasks: + - name: Upgrade all packages to the latest version + apt: + update_cache: yes + upgrade: yes + - name: Remove useless packages from the cache + apt: + autoclean: yes + - name: Remove dependencies that are no longer required + apt: + autoremove: yes +... +``` + **Run roles on Docker servers but Master** ```yaml - hosts: docker,!docker-master From bb5697881df11e8fa436103f977d1ca6620f91d1 Mon Sep 17 00:00:00 2001 From: Amaury Souza Date: Fri, 21 Feb 2020 12:44:30 -0300 Subject: [PATCH 2/2] Update README.md Deploy EC2 instances with Ansible playbook. --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 62b3cc9..fc7f345 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,57 @@ A playbook is the gathering between hosts where will be applied tasks. ... ``` +**Deploy EC2 instances with Ansible +``` +--- +- name: Creating Security Group + local_action: + module: ec2_group + name: "{{ security_group }}" + description: Security Group Giros + region: "{{ region }}" + rules: + - proto: tcp + from_port: 22 + to_port: 22 + cidr_ip: 0.0.0.0/0 + rules_egress: + - proto: all + cidr_ip: 0.0.0.0/0 + register: basic_firewall + +- name: Creating EC2 instance + local_action: ec2 + group={{ security_group }} + instance_type={{instance_type}} + image={{ image }} + wait=true + region={{ region }} + keypair={{ keypair }} + count={{ count }} + register: ec2 + + +- name: Adding instance for temp inventary + add_host: name={{ item.public_ip }} groups=giropops-new + with_items: "{{ ec2.instances }}" + +- name: Waiting for SSH + local_action: wait_for + host={{ item.public_ip }} + port=22 + state=started + with_items: "{{ ec2.instances }}" + +- name: Adding a tag name for instance + local_action: ec2_tag resource={{ item.id }} region={{ region }} state=present + with_items: "{{ ec2.instances }}" + args: + tags: + Name: DevOpsweek +... +``` + **Run roles on Docker servers but Master** ```yaml - hosts: docker,!docker-master