ansible 管理ldap

noteId: WEBd8c7143ba171ceae16542c366bf345d4 · 原始路径:/ALL/Ansible 自动化管理/Ansible 配置合集/Ansible 自动化管理-Linux/ansible 管理ldap.note

先配置好ldap,然后直接复制目录过去

1-ansible

---- name: ansible  hosts: all  gather_facts: false  tasks:    - name: CA      file:        path: /etc/ssl/globalcorp-ca        state: directory      register: file    - name: install      apt:        name:          - postfix          - chrony          - slapd          - openssl          - bind9          - dnsutils          - dbus          - nmap          - curl          - net-tools        update_cache: false    - name: start dbus      raw: |        systemctl start dbus      when: file.changed    - name: hostname      hostname:        name: "{{ inventory_hostname }}"    - name: bind9      copy:        src: /data/bind/        dest: /etc/bind/    - name: root hints      copy:        src: /data/root.hints        dest: /usr/share/dns    - name: postfix      copy:        src: /data/postfix/        dest: /etc/postfix/    - name: ssl      copy:        src: /data/ssl/        dest: /etc/ssl/    - name: slapd      copy:        src: /data/ldap/        dest: /etc/ldap/    - name: slapd      copy:        src: /data/slapd.d        dest: /etc/default    - name: slapd      copy:        src: /data/db/        dest: /var/lib/ldap/    - name: ldap port      copy:        src: /data/slapd        dest: /etc/default    - name: chrony      copy:        src: /data/chrony.conf        dest: /etc/chrony    - name: ca      copy:         src: /data/demoCA/        dest: /root/demoCA/    - name: ca      copy:         src: /data/ca.crt        dest: /usr/local/share/ca-certificates    - name: ca trust      raw: |        /usr/sbin/update-ca-certificates      when: file.changed    - name: ocsp      copy:        src: /data/ocsp.crt        dest: /root    - name: ocsp      copy:        src: /data/ocsp.key        dest: /root    - name: ocsp      copy:        src: /data/ca.crt        dest: /root    - name: ocsp      lineinfile:        path: /etc/crontab        line: "@reboot root /usr/bin/openssl ocsp -index /root/demoCA/index.txt -port 8080 -rsigner /root/ocsp.crt -rkey /root/ocsp.key -CA /root/ca.crt -text"    - name: restart      raw: |        chown openldap /etc/ssl/globalcorp-ca/*        chown -R openldap:openldap /etc/ldap/slapd.d/        systemctl restart bind9 slapd postfix chrony      when: file.changed    - name: reboot      reboot:        reboot_timeout: 3600      when: file.changed