The following will

  • create a group called ansible with a group ID of 30000
  • create a group called devops with a group ID of 30001
  • create the user ansible with a user ID of 30000 and a home directory of /home/ansible
  • set ansible user's primary group to ansible and secondary group to devops
  • set the password for the ansible user to London1
  • add the devops group to sudoers
groupadd --gid 30000 ansible && \
groupadd --gid 30001 devops && \
useradd --uid 30000 ansible -m -g ansible --groups devops && \
echo -e "London1\nLondon1" | passwd ansible && \
echo "%devops        ALL=(ALL)       NOPASSWD: ALL" > /etc/sudoers.d/10_devops