From a2a8303ffbddff8efe93cb54cc5e349e21ce072d Mon Sep 17 00:00:00 2001 From: veldrane Date: Mon, 23 Nov 2020 10:46:23 +0100 Subject: [PATCH] new elasticsearch host --- 16_elk/ansible/01_prepare_nodes.yaml | 1 + 16_elk/ansible/02_prepare_prometheus.yaml | 52 +++++++++++++++++++++++ 16_elk/ansible/03_extend_cluster.yaml | 37 ++++++++++++++++ 16_elk/ansible/README.md | 0 16_elk/ansible/include/_setup_vars.yaml | 39 +++++++++++++++++ 5 files changed, 129 insertions(+) create mode 120000 16_elk/ansible/01_prepare_nodes.yaml create mode 100644 16_elk/ansible/02_prepare_prometheus.yaml create mode 100644 16_elk/ansible/03_extend_cluster.yaml create mode 100644 16_elk/ansible/README.md create mode 100644 16_elk/ansible/include/_setup_vars.yaml diff --git a/16_elk/ansible/01_prepare_nodes.yaml b/16_elk/ansible/01_prepare_nodes.yaml new file mode 120000 index 0000000..36ecbd8 --- /dev/null +++ b/16_elk/ansible/01_prepare_nodes.yaml @@ -0,0 +1 @@ +../../99_newhost/ansible/01_prepare_nodes.yaml \ No newline at end of file diff --git a/16_elk/ansible/02_prepare_prometheus.yaml b/16_elk/ansible/02_prepare_prometheus.yaml new file mode 100644 index 0000000..e4b3569 --- /dev/null +++ b/16_elk/ansible/02_prepare_prometheus.yaml @@ -0,0 +1,52 @@ +--- +- hosts: localhost + become: true + gather_facts: no + tasks: + + - name: Set variables + include: include/_setup_vars.yaml + + - name: "Create ansible group for new hosts" + add_host: name="{{ ip }}" groups=newhost + + - name: Create prometheus data disk + shell: qemu-img create -f qcow2 {{ vms_dir }}/{{ fqdn }}/promvg.qcow2 {{ disksize }} + + - name: Attach disk to machine + shell: virsh attach-disk {{ fqdn }} --source {{ vms_dir }}/{{ fqdn }}/promvg.qcow2 --target vdb --subdriver qcow2 --targetbus virtio --persistent + + - name: Autostart of the machine + shell: virsh autostart {{ fqdn }} + +- hosts: newhost + become: true + gather_facts: no + tasks: + + - name: Set variables + include: include/_setup_vars.yaml + + - name: Setup firewall rules + shell: firewall-cmd --permanent --add-port=9090-9094/tcp --add-port=443/tcp ; firewall-cmd --reload + + - name: LV extend /lv-var + shell: lvresize /dev/rootvg/var -L+10G + + - name: Resize fs + shell: resize2fs /dev/rootvg/var + + - name: Create datavg and logical volume + shell: pvcreate /dev/vdb ; vgcreate promvg /dev/vdb ; lvcreate -n data -L50G promvg + + - name: Create fs + shell: mkfs.ext4 /dev/promvg/data + + - name: make directory /prometheus/data + shell: mkdir -p /prometheus/data + + - name: Add /prometheus/data to fstab + shell: echo '/dev/mapper/promvg-data /prometheus/data ext4 noatime,nodiratime 1 2' >> /etc/fstab + + - name: Mount /prometheus/data + shell: mount /prometheus/data diff --git a/16_elk/ansible/03_extend_cluster.yaml b/16_elk/ansible/03_extend_cluster.yaml new file mode 100644 index 0000000..31e5639 --- /dev/null +++ b/16_elk/ansible/03_extend_cluster.yaml @@ -0,0 +1,37 @@ +--- +- hosts: localhost + become: true + gather_facts: no + tasks: + + - name: Set variables + include: include/_setup_vars.yaml + + - name: "Create ansible group for new hosts" + add_host: name="{{ master }}" groups=newhost + +- hosts: newhost + become: true + gather_facts: no + tasks: + + - name: Set variables + include: include/_setup_vars.yaml + + - name: Copy cluster.ini + shell: cp /root/gshipley/cluster.ini /root/gshipley/prometheus.ini + + - name: Add new hosts + shell: echo "[new_nodes]" >> /root/gshipley/prometheus.ini ; echo "{{ fqdn }} openshift_node_group_name='node-config-prometheus'" >> /root/gshipley/prometheus.ini + + - name: Add section new nodes + shell: cd /root/gshipley ; sed -i -E 's/nodes$/nodes\nnew_nodes/' prometheus.ini + + - name: Add host to ansible host + shell: echo "{{ fqdn }}" >> /etc/ansible/hosts + + - name: setting up the node group + shell: cd /root/gshipley ; ansible-playbook -i prometheus.ini openshift-ansible/playbooks/openshift-master/openshift_node_group.yml + + - name: Add new node to the cluster + shell: cd /root/gshipley ; ansible-playbook -i prometheus.ini openshift-ansible/playbooks/openshift-node/scaleup.yml diff --git a/16_elk/ansible/README.md b/16_elk/ansible/README.md new file mode 100644 index 0000000..e69de29 diff --git a/16_elk/ansible/include/_setup_vars.yaml b/16_elk/ansible/include/_setup_vars.yaml new file mode 100644 index 0000000..7c0832e --- /dev/null +++ b/16_elk/ansible/include/_setup_vars.yaml @@ -0,0 +1,39 @@ +- name: Set global variables + set_fact: + virbr: "16" + netsuffix: "33" + hostname: "node33" + domain: "lab.local" + mem: "8G" + ipaserver: "freeipa.lab.local" + ipaip: "10.1.8.10" + ldapbase: "dc=lab,dc=local" + svcadmin: "admin" + adminpwd: "admin123" + template: "t_centos7" + template_dir: "/data/templates" + vms_dir: "/data/vms" + rootvg_size: 30 + + +- name: Set ip + set_fact: + ip: "10.1.{{ virbr }}.{{ netsuffix }}" + + + +- name: Set FQDN + set_fact: + fqdn: "{{ hostname }}.{{ domain }}" + +- name: Set REALM + set_fact: + realm: "{{ domain|upper }}" + +- name: Set disksize + set_fact: + disksize: "51G" + +- name: Set ocp master + set_fact: + master: "node11.lab.local"