windows setup for winrm, for Ansible

In order for Ansible to connect to your windows server, you need to open winrm,you can do it by putting the settings inn a ps1 (/var/www/html/w.ps1) file in your webserver with these contents:

Enable-PSRemoting
Set-Item -Path “WSMan:\localhost\Service\Auth\Basic” -value True
Set-Item -Path “WSMan:\localhost\Service\AllowUnencrypted” -value True
net localgroup “Remote Management Users” my_admin /add
net localgroup administrators my_admin /add

Then in the windows server, you can get it and run it using:
powershell “IEX(New-Object Net.WebClient).downloadString(‘http://10.4.192.192/w.ps1’)”

create Ansible role

To create a role use the ansible-galaxy command

$ ansible-galaxy init SSSD

then add something to main.yml

$ vi SSSD/tasks/main.yml

# tasks file for SSSD
#
– name: ensure sssd packages are installed
yum:
name: libselinux-python,realmd,sssd,oddjob,oddjob-mkhomedir,adcli,samba-common,samba-common-tools,ntpdate,ntp,sudo,krb5-workstation,openldap-clients,policycoreutils-python
state: present

– name: make sure line ‘dns=none’ is set in /etc/NetworkManager/NetworkManager.conf
ini_file:
path: /etc/NetworkManager/NetworkManager.conf
state: present
no_extra_spaces: yes
section: main
option: dns
value: none
owner: root
group: root
mode: 0644
backup: yes
notify:
– reload NetworkManager

– name: deploy resolv.conf template
template:
src: templates/resolv.conf.j2
dest: /etc/resolv.conf
owner: root
group: root
mode: 0644
backup: yes
notify:
– reload NetworkManager

– name: Check if machine is bound
shell: /bin/bash -c “realm list | grep sssd”
register: realmd_bound
changed_when: false
ignore_errors: true

– name: Add use_fully_qualified_names = False to /etc/sssd/sssd.conf
lineinfile:
dest: /etc/sssd/sssd.conf
line: ‘use_fully_qualified_names = False’
insertafter: ‘^\[domain/clarios.com\]’
notify:
– restart sssd
when: realmd_bound is failed

– name: Add fallback_homedir = /home/%u to /etc/sssd/sssd.conf
lineinfile:
dest: /etc/sssd/sssd.conf
line: ‘fallback_homedir = /home/%u’
insertafter: ‘^\[domain/clarios.com\]’
notify:
– restart sssd
when: realmd_bound is failed