Automated configuration of 389-DS using ansible

From Notes_Wiki
Revision as of 08:42, 11 April 2015 by Saurabh (talk | contribs)

<yambe:breadcrumb>389-DS|389-DS</yambe:breadcrumb> <yambe:breadcrumb>Ansible playbooks</yambe:breadcrumb>

Automated configuration of 389-DS using ansible

To configure 389-DS server using ansbile use following playbook:

---
- name: This file configures ldap server
  hosts: ldap
  remote_user: root

  vars:
    ldap_server_fqdn: ldap.purpletalk.com
    admin_password: rekall123
    administration_domain: purpletalk.com
       
  tasks:
  - name: Setup epel-repository
    yum: name=epel-release state=present

  - name: Create ldapadmin user and set its password
    user: name=ldapadmin password='$6$Itpwfz9La5$paVslBlJLsvk0QYVxf287fLb.WyKPLcryXhc5iWyZIRHEY6IEXeaLcONiTB0o.qdpyQIQyYI/.euZSPsFe6LT0' 

  - name: Install required packages (389-ds, openldap-clients, expect)
    yum: name={{item}} state=present
    with_items:
      - 389-ds
      - openldap-clients
      - expect

  - name: Copy server setup expect script
    template: src=setup-ds-admin.sh dest=/root/setup-ds-admin.sh

  - name: Set execute permissions on created script
    file: path=/root/setup-ds-admin.sh owner=root group=root mode=755

  - name: Execute server setup expect script
    shell: /root/setup-ds-admin.sh

  - name: Configure server to automatically start on reboot
    service: name="{{item}}" state=started enabled=yes
    with_items:
      - dirsrv-admin
      - dirsrv

This script assumes 'setup-ds-admin.sh' file in the same folder with following contents:

#!/usr/bin/expect -f

spawn setup-ds-admin.pl
expect "continue with set up"
send "yes\r"
expect "Would you like to continue"
send "yes\r"
expect "Choose a setup type"
send "2\r"
expect "Computer name"
send "{{ldap_server_fqdn}}\r"
expect "System User"
send "ldapadmin\r"
expect "System Group"
send "ldapadmin\r"
expect "configuration directory server"
send "no\r"
expect "administrator ID"
send "admin\r"
expect "Password"
send "{{admin_password}}\r"
expect "Password (confirm)"
send "{{admin_password}}\r"
expect "Administration Domain"
send "{{administration_domain}}\r"
expect "Directory server network port"
send "389\r"
expect "Directory server identifier"
send "\r"
expect "Suffix"
send "\r"
expect "Directory Manager DN"
send "\r"
expect "Password"
send "{{admin_password}}\r"
expect "Password (confirm)"
send "{{admin_password}}\r"
expect "Administration port"
send "9830\r"
expect "Are you ready to set up your servers"
send "yes\r"


expect "Not there for sure"
send_user "$expect_out(buffer)"

exit 0


<yambe:breadcrumb>389-DS|389-DS</yambe:breadcrumb> <yambe:breadcrumb>Ansible playbooks</yambe:breadcrumb>