Ansible playbook to automate security configurations of an EC2 instance

0 votes

I am creating an Ansible playbook that would automate the security configurations of creating an EC2 Intance. This is my playbook, but I get a lot of errors when I try to execute it.

- hosts:localhost
  tasks:
    - name:Setting up Security/Firewall Group
      ec2_group:
         name:aws-security
         description:Rules Allowing Traffic on port 22 and 80
         region: us-west-2
         rules:
          - proto: tcp
            from_port: 80
            to_port: 80
            cidr_ip: 0.0.0.0/0
          - 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
Jan 23 in Ansible by Kiara
30 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Kiara, your indentation is very wrong. Yaml files are very sensitive with spacing and indentation. 

Also keep your host as 'all'

- hosts: all
  tasks:
    - name: Setting up Security/Firewall Group
      ec2_group:
         name: aws_security_group
         description: Rules Allowing Traffic on port 22 and 80
         region: us-west-2
         rules:
          - proto: tcp
            from_port: 80
            to_port: 80
            cidr_ip: 0.0.0.0/0
          - 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
answered Jan 23 by Harsh

Related Questions In Ansible

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Playbook to add ec2 instance to ELB

Hey, @Kishore, try something like this: - hosts: ...READ MORE

answered Mar 25 in Ansible by Yesha
10 views
0 votes
0 answers

Error while executing playbook to start ec2 instance

I have a playbook that starts an ...READ MORE

Mar 29 in Ansible by Kalgi
55 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Role of subelement module in an Ansible playbook

Hey @Rahul thanks for a better question ...READ MORE

answered Jan 16 in Ansible by Emily
65 views
0 votes
1 answer

Is it possible to run an Ansible Playbook in python script?

Hey @Cerci, Of course its possible. You ...READ MORE

answered Jan 17 in Ansible by Nicolas
892 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.