diff --git a/ansible/roles/configure-nfs-client/tasks/main.yml b/ansible/roles/configure-nfs-client/tasks/main.yml new file mode 100644 index 0000000..aab11b1 --- /dev/null +++ b/ansible/roles/configure-nfs-client/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: install nfs client + become: true + ansible.builtin.apt: + name: + - nfs-common + when: ansible_os_family == "Debian" + +- name: create mount point + become: true + ansible.builtin.file: + path: /storage + state: directory + mode: "0755" + when: ansible_os_family == "Debian" + +- name: add nfs entry to fstab + become: true + ansible.builtin.lineinfile: + path: /etc/fstab + line: "{{ item }}" + state: present + create: yes + with_items: + - "10.10.0.7:/storage /storage nfs defaults 0 0" + +- name: mount nfs + become: true + ansible.builtin.shell: + cmd: "mount -a" + when: ansible_os_family == "Debian" diff --git a/ansible/roles/configure-nfs-server/tasks/main.yml b/ansible/roles/configure-nfs-server/tasks/main.yml new file mode 100644 index 0000000..c38a8f7 --- /dev/null +++ b/ansible/roles/configure-nfs-server/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: install nfsd + become: true + ansible.builtin.apt: + name: + - nfs-kernel-server + - nfs-common + when: ansible_os_family == "Debian" + +- name: configure nfsd + become: true + ansible.builtin.lineinfile: + path: /etc/exports + line: "{{ item }}" + state: present + create: yes + with_items: + - "/storage 10.10.0.4(rw,sync,no_subtree_check,no_root_squash)" + - "/storage 10.10.0.5(rw,sync,no_subtree_check,no_root_squash)" + - "/storage 10.10.0.6(rw,sync,no_subtree_check,no_root_squash)" + +- name: restart nfsd + become: true + ansible.builtin.service: + name: nfs-kernel-server + state: restarted + enabled: yes + when: ansible_os_family == "Debian" diff --git a/ansible/roles/elastic-apt/tasks/main.yml b/ansible/roles/elastic-apt/tasks/main.yml new file mode 100644 index 0000000..fa621e4 --- /dev/null +++ b/ansible/roles/elastic-apt/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Ensure required packages are installed + become: true + apt: + name: "{{ item }}" + with_items: ["software-properties-common", "gnupg"] + when: ansible_os_family == "Debian" + +- name: Add Elastic apt key + become: true + shell: + cmd: "wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic-keyring.gpg" + register: result + when: ansible_os_family == "Debian" + +- name: Print out result + debug: + msg: "{{ result.stdout }}" + +- name: Add Elastic repository + become: true + shell: + cmd: 'echo "deb [signed-by=/usr/share/keyrings/elastic-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list' + register: result + when: ansible_os_family == "Debian" + +- name: Print out results + debug: + msg: "{{ result.stdout }}" diff --git a/ansible/roles/logging/tasks/main.yml b/ansible/roles/logging/tasks/main.yml new file mode 100644 index 0000000..2161ef0 --- /dev/null +++ b/ansible/roles/logging/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Install logstash + become: true + apt: + name: logstash + state: present + update_cache: yes + when: ansible_os_family == "Debian" + +- name: Start and enable logstash + become: true + service: + name: logstash + state: started + enabled: yes + when: ansible_os_family == "Debian" + +- name: Copy logstash config file + become: true + copy: + src: logstash.conf + dest: /etc/logstash/conf.d/logstash.conf + when: ansible_os_family == "Debian"