Creating users is a very trivial task that requires time, especially if there is not a Active Directory mechanism integrated with the Linux servers. In order to make your life easier as an administrator you can run the below playbook that will create users based on a list and add them sudo capabilities.
Task 1 creates the users that have been specified on the loop section.
Task 2 creates the appropriate sudoers file
1 ---
2 - name: create sudoers users based on request
3 hosts: localhost
4 become: true
5 tasks:
6 - name: create users based on a list
7 user:
8 name: "{{ item }}"
9 password: "{{ '#Passw0rd#' | password_hash('sha512') }}"
10 shell: /bin/bash
11 loop:
12 - user1
13 - user2
14
15 - name: create sudoers file for user
16 copy:
17 content: '{{ item }} ALL = (ALL) ALL'
18 dest: "/etc/sudoers.d/{{item}}"
19 loop:
20 - user1
21 - user2
Run the playbook and verify that the password is correct and user has sudo capabilities.
This article will guide you implement automation on the deployment procedure of a VMware infrastructure. In more detail the ansible project that is listed on the bottom of the page will deploy VMs from a list that you provide on your VMware hypervisor.
The dependencies that are necessary for this solution to work are:
The community.vmware plugin which can be installed with:
If you try to connect with Ansible on a Windows machine with your active directory account you will get the error -> the specified credentials were rejected by the server
In order to connect through a domain account you should add some inventory variables and also install some additional components.
If you do not have the appropriate libraries installed, you should get the error shown on the below screenshot.
By trying to install kerberos and requests-kerberos through pip3 I got the error that is listed below.
Lets assume you have configured ansible on multiple Windows hosts in order to massively perform patches installation or execute commands. As explained in detail on my previous articles in order to be successful the connection method must be set as winrm (see below)
However if you state this connection method, you cannot connect to linux machines and delegate tasks. One example of this scenario is a windows patching mechanism with wsus and ansible. You can deploy the patches using winrm method but you cannot log output on your localhost as the connection must be changed to ssh.
In order to bypass this problem I added a new group on my inventory for localhost entry for which I specify the connection method and user
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy