Skip to content

Commit

Permalink
new elasticsearch host
Browse files Browse the repository at this point in the history
  • Loading branch information
veldrane committed Nov 23, 2020
1 parent c65410c commit a2a8303
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions 16_elk/ansible/01_prepare_nodes.yaml
52 changes: 52 additions & 0 deletions 16_elk/ansible/02_prepare_prometheus.yaml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions 16_elk/ansible/03_extend_cluster.yaml
Original file line number Diff line number Diff line change
@@ -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
Empty file added 16_elk/ansible/README.md
Empty file.
39 changes: 39 additions & 0 deletions 16_elk/ansible/include/_setup_vars.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit a2a8303

Please sign in to comment.