Fixes endpoints issues and pv issues.

This commit is contained in:
Pablo Moreno 2016-11-16 15:21:46 +00:00 committed by ant31
parent ce5d5f6603
commit 3187053094
3 changed files with 38 additions and 8 deletions

View file

@ -42,8 +42,36 @@
name: "{{ gluster_brick_name }}"
brick: "{{ gluster_brick_dir }}"
replicas: "{{ groups['gfs-cluster'] | length }}"
cluster: "{{ groups['gfs-cluster'] | map('extract', hostvars, ['ansible_eth0', 'ipv4', 'address']) | join(',') }}"
cluster: "{{ groups['gfs-cluster'] | map('extract', hostvars, ['ip']) | join(',') }}"
host: "{{ inventory_hostname }}"
force: yes
run_once: true
- name: Mount glusterfs to retrieve disk size
mount:
name: "{{ gluster_mount_dir }}"
src: "{{ hostvars[groups['gfs-cluster'][0]]['ip'] }}:/gluster"
fstype: glusterfs
opts: "defaults,_netdev"
state: mounted
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
- name: Get Gluster disk size
setup: filter=ansible_mounts
register: mounts_data
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
- name: Set Gluster disk size to variable
set_fact:
gluster_disk_size_gb: "{{ (mounts_data.ansible_facts.ansible_mounts | selectattr('mount', 'equalto', gluster_mount_dir) | map(attribute='size_total') | first | int / (1024*1024*1024)) | int }}"
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]
- name: Unmount glusterfs
mount:
name: "{{ gluster_mount_dir }}"
fstype: glusterfs
src: "{{ hostvars[groups['gfs-cluster'][0]]['ip'] }}:/gluster"
state: unmounted
when: groups['gfs-cluster'] is defined and inventory_hostname == groups['gfs-cluster'][0]

View file

@ -2,15 +2,14 @@
"kind": "Endpoints",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
"name": "glusterfs"
},
"subsets": [
{% for host in groups['gfs-cluster'] %}
{
"addresses": [
{
{% for host in groups['gfs-cluster'] %}
"ip": "{{hostvars[host]['ansible_eth0']['ipv4']['address']}}"{%- if not loop.last %}, {% endif -%}
{% endfor %}
{
"ip": "{{hostvars[host]['ip']}}"
}
],
"ports": [
@ -18,7 +17,8 @@
"port": 1
}
]
}
}{%- if not loop.last %}, {% endif -%}
{% endfor %}
]
}

View file

@ -1,8 +1,10 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: gluster-default-volume
name: glusterfs
spec:
capacity:
storage: "{{ hostvars[groups['gfs-cluster'][0]].gluster_disk_size_gb }}Gi"
accessModes:
- ReadWriteMany
glusterfs: