Dawny33
Dawny33

Reputation: 11061

sudo error even after using "become: yes" in Ansible

I have used the become: yes condition in my .yml file. Yet, I'm getting the following error:

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE"}

This is my Ansible playbook for reference:

- hosts: localhost
  connection: local
  remote_user: test
  become: yes
  gather_facts: no
  vars_files: 
  - files/awscreds.yml
  - files/info.yml
  tasks:
    - name: Basic provisioning of EC2 instances
      ec2:
        aws_access_key: "{{ aws_id }}"
        aws_secret_key: "{{ aws_key }}"
        region: "{{ aws_region }}"
        image: "{{ standard_ami }}"
        instance_type: "{{ free_instance }}"
        key_name: "{{ ssh_keyname }}"
        count: 1
        state: present
        group_id: "{{ secgroup_id }}"
        wait: no
        instance_tags:
          Name: Dawny33_template
      register: e2info
    - name: Print the results
      debug: var=ec2info

Where did I go wrong here?

Upvotes: 0

Views: 640

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68229

  1. You don't need sudo to run ec2 module.
  2. Error sudo: a password is required suggests that you don't have passwordless sudo set up.

Upvotes: 2

Related Questions