gsoft-inc/ansible-role-azure-devops-agent

Group az_devops_agent does not exist error on Ubuntu 20.04

Opened this issue · 1 comments

alxm8 commented

Trying to get this working using ubuntu 20.04 vm:

error in ansible is: fatal: [localhost]: FAILED! => {"changed": false, "msg": "Group az_devops_agent does not exist"}

vagrant file below:

vagrant file

Vagrant.configure("2") do |config|
    config.vm.box = "generic/ubuntu2004"
    config.vm.provider "hyper-v"
    config.vm.provision "shell",
      inline: "echo installing apps..."
    config.vm.provision :shell, path: "./ansible.sh"
    config.vm.provider "hyperv" do |h, override|
      # Display the VirtualBox GUI when booting the machine
      h.cpus = 2
      h.maxmemory = 2048  
      # Customize the amount of memory on the VM:
      h.memory = 2048
    end
end

./ansible.sh file stored in same folder as vagrantfile

#!/bin/bash -eux

# Install Ansible repository.
sudo apt -y update && apt-get -y upgrade
sudo apt -y install software-properties-common
sudo apt-add-repository ppa:ansible/ansible

# Install Ansible.
sudo apt -y update
sudo apt -y install ansible`

shell commands used to replicate the issue... using local ansible exec

#download the ansible role
ansible-galaxy install gsoft.azure_devops_agent
#make directories
mkdir ~/ansible/
mkdir ~/ansible/azure_devops_agent_play
#create play file
touch ~/ansible/azure_devops_agent_play/main.yml
#add playbook content to file
tee -a ~/ansible/azure_devops_agent_play/main.yml <<EOF
---
- name: "Install devops agent"
  hosts: localhost
  become: yes
  become_user: root
  roles:
    - gsoft.azure_devops_agent
  vars:
    - az_devops_agent_role: build
    - az_devops_accountname: "orgname"
    - az_devops_accesstoken: "xxxxxxxxxxxxxxx"

EOF
ansible-playbook main.yml

error message

<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1647628396.287585-29548-243434691462664/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "append": false,
            "authorization": null,
            "comment": "Azure DevOps Agent",
            "create_home": true,
            "expires": null,
            "force": false,
            "generate_ssh_key": null,
            "group": "az_devops_agent",
            "groups": null,
            "hidden": null,
            "home": null,
            "local": null,
            "login_class": null,
            "move_home": false,
            "name": "az_devops_agent",
            "non_unique": false,
            "password": null,
            "password_expire_max": null,
            "password_expire_min": null,
            "password_lock": null,
            "profile": null,
            "remove": false,
            "role": null,
            "seuser": null,
            "shell": "/bin/bash",
            "skeleton": null,
            "ssh_key_bits": 0,
            "ssh_key_comment": "ansible-generated on ubuntu2004.localdomain",
            "ssh_key_file": null,
            "ssh_key_passphrase": null,
            "ssh_key_type": "rsa",
            "state": "present",
            "system": false,
            "uid": null,
            "umask": null,
            "update_password": "always"
        }
    },
    "msg": "Group az_devops_agent does not exist"
}
TASK [gsoft.azure_devops_agent : Add an agent user] ***********************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Group az_devops_agent does not exist"}

help is appreciated!

this happened since #56

just define az_devops_agent_group as variable with already existing group.