How to Connect Ansible on Windows from Ubuntu?

I am going to shortly present you ways to hook up with Home windows server from Ansible on Ubuntu.

To comply with the steps beneath, Python 3.x and Ansible should be put in on each techniques. You possibly can comply with the articles beneath should you need assistance.

Easy methods to set up and configure Ansible on Ubuntu?

How do I set up Ansible on Home windows?

Under are the main points of each servers I take advantage of:

  • Ansible Controller – 192.168.0.108
  • Home windows Server – 192.168.0.102

Step 1: Create an Ansible Home windows consumer

Create a brand new consumer to arrange the Ansible Home windows connection.

  • Open Laptop Administration in your Home windows system and go to Native Customers and Teams.
  • Proper-click Customers and create a brand new consumer.
  • Choose the Password by no means expires examine field and click on Create.

resilient user

  • Now, among the many obtainable teams, right-click on the Directors group and click on on properties.
  • Click on Add and enter ansible within the object names.
  • Click on the examine names possibility after which click on Okay.

defensive groups

Now an ansible consumer on Home windows machine is prepared.

Step 2: Arrange Libraries and WinRM

Go to your Anible controller machine, replace it and set up the libraries beneath.

geekflare@bestnich:~$ sudo apt-get replace
geekflare@bestnich:~$ sudo apt-get set up gcc python-dev
geekflare@bestnich:~$ sudo apt set up python3-pip

WinRM stands for Home windows Distant Administration. Permits you to carry out administrative duties on distant Home windows techniques. We are going to set up python3-winrma Python consumer used to hook up with the Home windows system.

geekflare@bestnich:~$ sudo apt-get set up python3-winrm
Studying bundle lists... Carried out
Constructing dependency tree
Studying state info... Carried out
The next packages have been robotically put in and are not required:
gyp libc-ares2 libhttp-parser2.8 libjs-async libjs-inherits libjs-is-typedarray libjs-node-uuid libuv1 libuv1-dev node-abbrev node-ajv
node-ansi node-ansi-color-table node-ansi-regex node-ansi-styles node-ansistyles node-aproba node-archy node-are-we-there-yet node-async

node-validate-npm-package-license node-wcwidth.js node-which node-which-module node-wide-align node-wrap-ansi node-wrappy node-y18n
node-yallist node-yargs node-yargs-parser nodejs nodejs-doc
Use 'sudo apt autoremove' to take away them.
The next extra packages will likely be put in:
python3-kerberos python3-ntlm-auth python3-requests-kerberos python3-requests-ntlm python3-xmltodict
The next NEW packages will likely be put in:
python3-kerberos python3-ntlm-auth python3-requests-kerberos python3-requests-ntlm python3-winrm python3-xmltodict
0 upgraded, 6 newly put in, 0 to take away and 231 not upgraded.
Have to get 84.8 kB of archives.
After this operation, 442 kB of extra disk house will likely be used.
Do you wish to proceed? [Y/n] Y
Get:1 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-kerberos amd64 1.1.14-1build1 [16.8 kB]
Get:2 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-ntlm-auth all 1.1.0-1 [19.6 kB]
Get:3 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-requests-kerberos all 0.11.0-2 [10.1 kB]
Get:4 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-requests-ntlm all 1.1.0-1 [6,004 B]
Get:5 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-xmltodict all 0.11.0-2 [10.6 kB]
Get:6 http://old-releases.ubuntu.com/ubuntu cosmic/universe amd64 python3-winrm all 0.3.0-2 [21.7 kB]
Fetched 84.8 kB in 1s (70.3 kB/s)
Choosing beforehand unselected bundle python3-kerberos.
(Studying database ... 244430 recordsdata and directories presently put in.)
Making ready to unpack .../0-python3-kerberos_1.1.14-1build1_amd64.deb ...
Unpacking python3-kerberos (1.1.14-1build1) ...
Choosing beforehand unselected bundle python3-ntlm-auth.
Choosing beforehand unselected bundle python3-xmltodict.
Making ready to unpack .../4-python3-xmltodict_0.11.0-2_all.deb ...
Unpacking python3-xmltodict (0.11.0-2) ...
Choosing beforehand unselected bundle python3-winrm.
Making ready to unpack .../5-python3-winrm_0.3.0-2_all.deb ...
Unpacking python3-winrm (0.3.0-2) ...
Organising python3-kerberos (1.1.14-1build1) ...
Organising python3-winrm (0.3.0-2) ...

Step 3: Replace the Ansible Stock file

Now I’ll edit the ansible hosts file with the Home windows system IP handle. So Anible will now know which Home windows system to hook up with.

geekflare@bestnich:~$ sudo gedit /and many others/ansible/hosts

[win]
192.168.0.102

Step 4: Replace the Ansible Group variables

Create a folder to put variables that want to hook up with the Home windows system.

geekflare@bestnich:~$ mkdir /and many others/ansible/group_vars
geekflare@bestnich:~$ sudo chmod -R 777 /and many others/ansible/

Create a file win.yaml and put the consumer information you created in step one, and a few extra variables wanted to hook up with the Home windows system.

geekflare@bestnich:~$ gedit /and many others/ansible/group_vars/win.yaml
---

ansible_user: ansible

ansible_password: ansible

ansible_connection: winrm

ansible_winrm_server_cert_validation: ignore

ansible_winrm_transport: primary

ansible_winrm_port: 5985

ansible_python_interpreter: C:UsersgeekflareAppDataLocalProgramsPythonPython37python

Step 5: Configure Home windows servers to handle

Open your Home windows PowerShell and improve it. You will need to have Powershell 3.0 and .NET Framework 4.0 current on the Home windows machine.

PS C:WINDOWSsystem32> $url = "https://uncooked.githubusercontent.com/jborean93/ansible-windows/grasp/scripts/Improve-PowerShell.ps1"
PS C:WINDOWSsystem32> $file = "$env:tempUpgrade-PowerShell.ps1"
PS C:WINDOWSsystem32> $username = "ansible"
PS C:WINDOWSsystem32> $password = "ansible"
PS C:WINDOWSsystem32> (New-Object -TypeName System.Internet.WebClient).DownloadFile($url, $file)
PS C:WINDOWSsystem32> Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Power
PS C:WINDOWSsystem32> &$file -Model 5.1 -Username $username -Password $password -Verbose

To configure WinRM on a Home windows system with ansible, an exterior configuration script is supplied by ansible. Run the script in PowerShell.

PS C:WINDOWSsystem32> $url = "https://uncooked.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
PS C:WINDOWSsystem32> $file = "$env:tempConfigureRemotingForAnsible.ps1"
PS C:WINDOWSsystem32> (New-Object -TypeName System.Internet.WebClient).DownloadFile($url, $file)
PS C:WINDOWSsystem32> powershell.exe -ExecutionPolicy ByPass -File $file
PS C:WINDOWSsystem32> winrm enumerate winrm/config/Listener

Listener
Handle = *
Transport = HTTP
Port = 5985
Hostname
Enabled = true
URLPrefix = wsman

CertificateThumbprint
ListeningOn = 127.0.0.1, 169.254.8.240, 169.254.36.9, 169.254.102.217, 169.254.215.170, 192.168.0.102, ::1, fe80::3131:c6d7:9ef5:8f0percent7, fe80::51b7:9134:550d:d7aapercent22, fe80::88f1:1229:e1dd:2409percent16, fe80::99cf:5796:4f8e:f5c1percent15, fe80::fd77:c19d:e0f2:66d9percent9

Listener
Handle = *
Transport = HTTPS
Port = 5986
Hostname = DESKTOP-2L8QMI6
Enabled = true
URLPrefix = wsman

CertificateThumbprint = C83B3FC8B274D0B650F0FD647DC7AC129BBE3FA0
ListeningOn = 127.0.0.1, 169.254.8.240, 169.254.36.9, 169.254.102.217, 169.254.215.170, 192.168.0.102, ::1, fe80::3131:c6d7:9ef5:8f0percent7, fe80::51b7:9134:550d:d7aapercent22, fe80::88f1:1229:e1dd:2409percent16, fe80::99cf:5796:4f8e:f5c1percent15, fe80::fd77:c19d:e0f2:66d9percent9

Set winrm to permit HTTP visitors.

PS C:WINDOWSsystem32> winrm set winrm/config/service '@{AllowUnencrypted="true"}'
Service
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)

MaxConcurrentOperations = 4294967295

MaxConcurrentOperationsPerUser = 1500

EnumerationTimeoutms = 240000
MaxConnections = 300

MaxPacketRetrievalTimeSeconds = 120
AllowUnencrypted = true
Auth
Primary = true
Kerberos = true
Negotiate = true
Certificates = false
CredSSP = false

CbtHardeningLevel = Relaxed
DefaultPorts
HTTP = 5985
HTTPS = 5986
IPv4Filter = *
IPv6Filter = *

EnableCompatibilityHttpListener = false

EnableCompatibilityHttpsListener = false

CertificateThumbprint
AllowRemoteAccess = true

Set the authentication in wim to primary.

PS C:WINDOWSsystem32> winrm set winrm/config/service/auth '@{Primary="true"}'
Auth
Primary = true
Kerberos = true
Negotiate = true
Certificates = false
CredSSP = false
CbtHardeningLevel = Relaxed

Step 6: Take a look at the connectivity to the Home windows Server

Now all of the steps on the machine are accomplished. Go to the ansible controller machine and ping the Home windows Server machine utilizing win_ping weatherable module.

geekflare@bestnich:~$ ansible win -m win_ping
192.168.0.102 | SUCCESS => {

"modified": false,
"ping": "pong"
}

The success message signifies that the connection has been established. Now the Home windows system is able to be managed remotely from the Ansible operating on Ubuntu.

Leave a Comment

porno izle altyazılı porno porno