Setup Terraform and Ansible for Windows provisionon CentOS

Provisioning Windows machines with Terraform is easy. Configuring Windows machines with Ansible is also not complex. However, it's a little bit challenging to combine them. The following steps are some ideas about handling a Windows machine from provisioning to post configuration without modifying the winrm configuration on the guest operating system.

  1. Install required repos for yum.
yum -y install
yum -y install
yum -y install
yum -y install epel-release
yum -y install yum-utils
yum-config-manager --add-repo
  1. Install Terraform.
sudo yum -y install terraform
  1. Install Ansible.
sudo yum -y install ansible
  1. Install Kerberos.
yum -y install gcc python-devel krb5-devel krb5-libs krb5-workstation
  1. Install pip.
sudo yum -y install python-pip

# You probably need the following packages if you are using VPN
pip install pysocks
  1. Install pywinrm[kerberos].
pip install pywinrm[kerberos]
  1. Configure /etc/krb5.conf.
    The following are the required lines. Please make sure to change the domain name to yours. And it's case-sensitive.
    dns_lookup_realm = true
    dns_lookup_kdc = true
    forward = true
    forwardable = true
    default_realm = ZHENGWU.ORG
    kdc = DC.ZHENGWU.ORG
    admin_server = DC.ZHENGWU.ORG
[domain_realm] = ZHENGWU.ORG = ZHENGWU.ORG
  1. Create an Ansible inventory file.
[win] #Group name #This is the target server list
    ansible_user=administrator #It's better a domain admin account.
    ansible_password=P@ssw0rd #Change this password
    ansible_winrm_transport=kerberos     ansible_winrm_server_cert_validation=ignore
  1. Run Ansible win_ping test.
ansible <group in inventory file> -m win_ping -i <inventory file>

Popular posts from this blog

Moving to

How to Use Proxy on WSL 2

Connect-NsxtServer shows "Unable to connect to the remote server"