HOSTNAMEDNS RECORD(S)IPV4 ADDRESSIPV6 ADDRESS
BR-CL-DHCP-
Clients on BR‑CLIENT will be configured automatically using Ansible playbooks from BR‑SRV.
For testing purposes, only BR‑CL is used. It is already preconfigured: - SSH enabled - SSH key
authentication enabled
A preconfigured hosts file exists on BR‑SRV: /etc/ansible/hosts with exactly one host entry. - Do not change this file.
Ensure that BR‑CL has 10.20.30.50/24 (via DHCP or static configuration) so SSH works. Connect from BR‑SRV using user ansible (Passw0rd!) with a preinstalled private key.
Once BR‑CL network is working, create a snapshot called MarkingStart.
For marking: BR‑CL will be restored to MarkingStart, and playbooks will be run in order using: ansibleplaybook playbookname.yml Create the following playbooks in /etc/ansible/playbooks:
  1. 1-basic.yml ▪ Configure hostname, time zone, NTP. ▪ Hostname must come from the hostname variable in /etc/ansible/hosts. ▪ NTP must synchronize to R‑BR.
  2. 2-syslog.yml ▪ Send logs to BR‑SRV syslog TLS.
  3. 3-snmp.yml ▪ Configure SNMP so Zabbix can read CPU usage.
  4. 4-ldap.yml ▪ Configure LDAP authentication using ldap.vikingtoys.dk.
  5. 5-share.yml ▪ Configure automatic mounting of the shared resource.
  6. 6-webserver.yml ▪ Install and configure a web server (HTTP + HTTPS). ▪ The page must show: Website of <hostname> (hostname from /etc/ansible/hosts).

ANSIBLE на BR-SRV

--> vi /etc/ansible/hosts
=========================
[BR]
BR-CL
 
ansible_user: root
ansible_ssh_pass: 123456
ansible_host_key_checking: false
=========================
 
mkdir /etc/ansible/playbooks
mkdir /etc/ansible/playbooks/group_vars
 
--> vi /etc/ansible/playbooks/group_vars/BR
=========================
=========================

1-basic.yml

- name: 1-basic.yml
  hosts: all
  tasks:
    - name: hostname
      hostname: 
        name: "{{ inventory_hostname }}"
        
    - name: timezone
      timezone: 
        name: "Europe/Stockholm"
        
    - name: NTP
      copy: 
        src: /etc/ansible/playbooks/temp/timesyncd.conf # Туда поставить и поменять адрес
        dest: /etc/systemd/timesyncd.conf
      notify: NTP restart
      
  handlers: 
    - name: NTP restart
      service:
        name: systemd-timesyncd
        state: restarted

2-syslog.yml

- name: 2-syslog.yml
  hosts: all
  tasks:
    - name: install rsyslog
      apt:
        name: rsyslog
    - name: rsyslog conf
      copy:
        src: /ansible/temp/rsyslog.conf
        dest: /etc/
      notify: rsyslog restart
 
  handlers:
    - name: rsyslog restart
      service:
        name: rsyslog
        state: restarted

3-snmp.yml

- name: 3-snmp.yml
  hosts: all
  tasks:
    - name: install
      apt:
        name: snmpd
    - name: copy conf
      template:
        src: /ansible/temp/snmpd.conf
        dest: /etc/snmp/
      notify: restart
 
  handlers:
    - name: restart
      service:
        name: snmpd
        state: restarted

4-ldap.yml

- name: 4-ldap.yml
  hosts: all
  tasks:
    - name: install
      apt:
        name: libpam-ldapd
    - name: copy nsswitch.conf
      copy:
        src: /etc/ansible/temp/nsswitch.conf
        dest: /etc/
 
    - name: nslcd
      copy:
        dest: /etc/nslcd.conf
        content: |
          uid nslcd
          gid nslcd
          uri ldap://10.10.10.11
          base dc=vikingtoys,dc=dk
      notify: restart nslcd
 
    - name: pam homedir
      copy:
        src: /etc/ansible/temp/common-session
        dest: /etc/pam.d/
 
  handlers:
    - name: restart nslcd
      service:
        name: nslcd
        state: restarted

5-share.yml

- name: 5-share.yml
  hosts: all
  tasks:
    - name: install libpam-mount
      apt:
        name: libpam-mount
    - name: install cifs-utils
      apt:
        name: cifs-utils
 
    - name: copy pam_mount.conf.xml
      copy:
        src: /ansible/conf/pam_mount.conf.xml
        dest: /etc/security/

6-webserver.yml

- name: 6-webserver.yml
  hosts: all
  tasks:
    - name: install apache2
      apt:
        name: apache2
 
    - name: copy ca
      copy:
        dest: /ca
        src: /etc/ansible/temp/ca/
      notify: apache2
 
    - name: create diretory
      file:
        path: /var/www/site
        state: directory
	  notify: apache2
 
    - name: create index.html
      copy:
        dest: /var/www/site/index.html
        content: Website of "{{inventory_hostname}}"
      notify: apache2
 
    - name: deleate defauly page
      file:
        path: /etc/apache2/sites-enabled/000-default.conf
        state: absent
      notify: apache2
 
    - name: site.conf
      copy:
        dest: /etc/apache2/sites-enabled/site.conf
        src: /etc/ansible/temp/site.conf
      notify: apache2
      
    - name: a2enmode ssl.load
      file:
        src: /etc/apache2/mods-available/ssl.load
        path: /etc/apache2/mods-enabled/ssl.load
        state: link
      notify: apache2
      
    - name: a2enmode ssl.conf
      file:
        src: /etc/apache2/mods-available/ssl.conf
        path: /etc/apache2/mods-enabled/ssl.conf
        state: link
      notify: apache2
      
    - name: a2enmode ssl socache_shmcb.load
      file:
        src: /etc/apache2/mods-available/socache_shmcb.load
        path: /etc/apache2/mods-enabled/socache_shmcb.load
        state: link
      notify: apache2
 
  handlers:
    - name: apache2
      service:
        name: apache2
        state: reloaded