ceph-mon/mds: fix fqdn

closes #596

Signed-off-by: Sébastien Han <seb@redhat.com>
pull/599/head
Sébastien Han 2016-03-03 11:03:03 +01:00
parent 1372af4cd6
commit 378aadf3e3
5 changed files with 49 additions and 33 deletions

View File

@ -13,7 +13,7 @@
- name: restart ceph mons with systemd - name: restart ceph mons with systemd
service: service:
name: ceph-mon@{{ ansible_hostname }} name: ceph-mon@{{ monitor_name }}
state: restarted state: restarted
when: when:
socket.rc == 0 and socket.rc == 0 and
@ -74,7 +74,7 @@
- name: restart ceph mdss with systemd - name: restart ceph mdss with systemd
service: service:
name: ceph-mds@{{ ansible_hostname }} name: ceph-mds@{{ mds_name }}
state: restarted state: restarted
when: when:
socket.rc == 0 and socket.rc == 0 and

View File

@ -93,7 +93,7 @@ debug auth = {{ debug_mon_level }}
[mon.{{ hostvars[host]['ansible_fqdn'] }}] [mon.{{ hostvars[host]['ansible_fqdn'] }}]
host = {{ hostvars[host]['ansible_fqdn'] }} host = {{ hostvars[host]['ansible_fqdn'] }}
mon addr = {{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }} mon addr = {{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }}
{% else %} {% elif hostvars[host]['ansible_hostname'] is defined %}
[mon.{{ hostvars[host]['ansible_hostname'] }}] [mon.{{ hostvars[host]['ansible_hostname'] }}]
host = {{ hostvars[host]['ansible_hostname'] }} host = {{ hostvars[host]['ansible_hostname'] }}
mon addr = {{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }} mon addr = {{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }}
@ -155,18 +155,18 @@ osd deep scrub stride = {{ osd_deep_scrub_stride }}
{% if hostvars[host]['ansible_fqdn'] is defined and mds_use_fqdn %} {% if hostvars[host]['ansible_fqdn'] is defined and mds_use_fqdn %}
[mds.{{ hostvars[host]['ansible_fqdn'] }}] [mds.{{ hostvars[host]['ansible_fqdn'] }}]
host = {{ hostvars[host]['ansible_fqdn'] }} host = {{ hostvars[host]['ansible_fqdn'] }}
{% else %} {% elif hostvars[host]['ansible_hostname'] is defined %}
[mds.{{ hostvars[host]['ansible_hostname'] }}] [mds.{{ hostvars[host]['ansible_hostname'] }}]
host = {{ hostvars[host]['ansible_hostname'] }} host = {{ hostvars[host]['ansible_hostname'] }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %}
{% if enable_debug_mds %} {% if enable_debug_mds %}
debug mds = {{ debug_mds_level }} debug mds = {{ debug_mds_level }}
debug mds balancer = {{ debug_mds_level }} debug mds balancer = {{ debug_mds_level }}
debug mds log = {{ debug_mds_level }} debug mds log = {{ debug_mds_level }}
debug mds migrator = {{ debug_mds_level }} debug mds migrator = {{ debug_mds_level }}
{% endif %} {% endif %}
{% endif %}
{% if groups[rgw_group_name] is defined %} {% if groups[rgw_group_name] is defined %}
{% for host in groups[rgw_group_name] %} {% for host in groups[rgw_group_name] %}

View File

@ -1,4 +1,12 @@
--- ---
- set_fact:
mds_name: "{{ ansible_hostname }}"
when: not mds_use_fqdn
- set_fact:
mds_name: "{{ ansible_fqdn }}"
when: mds_use_fqdn
- name: create bootstrap-mds directory - name: create bootstrap-mds directory
file: file:
path: /var/lib/ceph/bootstrap-mds/ path: /var/lib/ceph/bootstrap-mds/
@ -23,22 +31,22 @@
- name: create mds directory - name: create mds directory
file: file:
path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }} path: /var/lib/ceph/mds/ceph-{{ mds_name }}
state: directory state: directory
owner: "{{ dir_owner }}" owner: "{{ dir_owner }}"
group: "{{ dir_group }}" group: "{{ dir_group }}"
mode: "{{ dir_mode }}" mode: "{{ dir_mode }}"
- name: create mds keyring - name: create mds keyring
command: ceph --cluster ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create mds.{{ ansible_hostname }} osd 'allow rwx' mds 'allow' mon 'allow profile mds' -o /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring command: ceph --cluster ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create mds.{{ mds_name }} osd 'allow rwx' mds 'allow' mon 'allow profile mds' -o /var/lib/ceph/mds/ceph-{{ mds_name }}/keyring
args: args:
creates: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring creates: /var/lib/ceph/mds/ceph-{{ mds_name }}/keyring
changed_when: false changed_when: false
when: cephx when: cephx
- name: set mds key permissions - name: set mds key permissions
file: file:
path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring path: /var/lib/ceph/mds/ceph-{{ mds_name }}/keyring
mode: "{{ key_mode }}" mode: "{{ key_mode }}"
owner: "{{ key_owner }}" owner: "{{ key_owner }}"
group: "{{ key_group }}" group: "{{ key_group }}"
@ -46,7 +54,7 @@
- name: activate metadata server with upstart - name: activate metadata server with upstart
file: file:
path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/{{ item }} path: /var/lib/ceph/mds/ceph-{{ mds_name }}/{{ item }}
state: touch state: touch
owner: "{{ activate_file_owner }}" owner: "{{ activate_file_owner }}"
group: "{{ activate_file_group }}" group: "{{ activate_file_group }}"
@ -59,7 +67,7 @@
- name: activate metadata server with sysvinit - name: activate metadata server with sysvinit
file: file:
path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/{{ item }} path: /var/lib/ceph/mds/ceph-{{ mds_name }}/{{ item }}
state: touch state: touch
owner: "{{ activate_file_owner }}" owner: "{{ activate_file_owner }}"
group: "{{ activate_file_group }}" group: "{{ activate_file_group }}"
@ -73,7 +81,7 @@
- name: enable systemd unit file for mds instance (for or after infernalis) - name: enable systemd unit file for mds instance (for or after infernalis)
file: file:
src: /usr/lib/systemd/system/ceph-mds@.service src: /usr/lib/systemd/system/ceph-mds@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ ansible_hostname }}.service dest: /etc/systemd/system/multi-user.target.wants/ceph-mds@{{ mds_name }}.service
state: link state: link
changed_when: false changed_when: false
failed_when: false failed_when: false
@ -86,7 +94,7 @@
name: ceph-mds name: ceph-mds
state: started state: started
enabled: yes enabled: yes
args: "id={{ ansible_hostname }}" args: "id={{ mds_name }}"
changed_when: false changed_when: false
when: ansible_distribution == "Ubuntu" when: ansible_distribution == "Ubuntu"
@ -95,7 +103,7 @@
name: ceph name: ceph
state: started state: started
enabled: yes enabled: yes
args: mds.{{ ansible_hostname }} args: mds.{{ mds_name }}
changed_when: false changed_when: false
when: when:
ansible_distribution != "Ubuntu" and ansible_distribution != "Ubuntu" and
@ -103,7 +111,7 @@
- name: start and add that the metadata service to the init sequence (for or after infernalis) - name: start and add that the metadata service to the init sequence (for or after infernalis)
service: service:
name: ceph-mds@{{ ansible_hostname }} name: ceph-mds@{{ mds_name }}
state: started state: started
enabled: yes enabled: yes
changed_when: false changed_when: false

View File

@ -14,15 +14,23 @@
become: false become: false
when: cephx when: cephx
- set_fact:
monitor_name: "{{ ansible_hostname }}"
when: not mon_use_fqdn
- set_fact:
monitor_name: "{{ ansible_fqdn }}"
when: mon_use_fqdn
- name: create monitor initial keyring - name: create monitor initial keyring
command: ceph-authtool /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} --create-keyring --name=mon. --add-key={{ monitor_secret }} --cap mon 'allow *' command: ceph-authtool /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }} --create-keyring --name=mon. --add-key={{ monitor_secret }} --cap mon 'allow *'
args: args:
creates: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} creates: /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
when: cephx when: cephx
- name: set initial monitor key permissions - name: set initial monitor key permissions
file: file:
path: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} path: /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
mode: "{{ key_mode }}" mode: "{{ key_mode }}"
owner: "{{ key_owner }}" owner: "{{ key_owner }}"
group: "{{ key_group }}" group: "{{ key_group }}"
@ -30,40 +38,40 @@
- name: create monitor directory - name: create monitor directory
file: file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }} path: /var/lib/ceph/mon/ceph-{{ monitor_name }}
state: directory state: directory
owner: "{{ dir_owner }}" owner: "{{ dir_owner }}"
group: "{{ dir_group }}" group: "{{ dir_group }}"
mode: "{{ dir_mode }}" mode: "{{ dir_mode }}"
- name: ceph monitor mkfs with keyring (for or after infernalis release) - name: ceph monitor mkfs with keyring (for or after infernalis release)
command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
args: args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
when: when:
cephx and cephx and
is_ceph_infernalis is_ceph_infernalis
- name: ceph monitor mkfs without keyring (for or after infernalis release) - name: ceph monitor mkfs without keyring (for or after infernalis release)
command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }}
args: args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/store.db creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
when: when:
not cephx and not cephx and
is_ceph_infernalis is_ceph_infernalis
- name: ceph monitor mkfs with keyring (before infernalis release) - name: ceph monitor mkfs with keyring (before infernalis release)
command: ceph-mon --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
args: args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
when: when:
cephx and cephx and
not is_ceph_infernalis not is_ceph_infernalis
- name: ceph monitor mkfs without keyring (before infernalis release) - name: ceph monitor mkfs without keyring (before infernalis release)
command: ceph-mon --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }}
args: args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/store.db creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
when: when:
not cephx and not cephx and
not is_ceph_infernalis not is_ceph_infernalis

View File

@ -1,7 +1,7 @@
--- ---
- name: activate monitor with upstart - name: activate monitor with upstart
file: file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/{{ item }} path: /var/lib/ceph/mon/ceph-{{ monitor_name }}/{{ item }}
state: touch state: touch
owner: "{{ activate_file_owner }}" owner: "{{ activate_file_owner }}"
group: "{{ activate_file_group }}" group: "{{ activate_file_group }}"
@ -17,7 +17,7 @@
name: ceph-mon name: ceph-mon
state: started state: started
enabled: yes enabled: yes
args: "id={{ ansible_hostname }}" args: "id={{ monitor_name }}"
when: ansible_distribution == "Ubuntu" when: ansible_distribution == "Ubuntu"
# NOTE (leseb): somehow the service ansible module is messing things up # NOTE (leseb): somehow the service ansible module is messing things up
@ -32,7 +32,7 @@
- name: enable systemd unit file for mon instance (for or after infernalis) - name: enable systemd unit file for mon instance (for or after infernalis)
file: file:
src: /usr/lib/systemd/system/ceph-mon@.service src: /usr/lib/systemd/system/ceph-mon@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-mon@{{ ansible_hostname }}.service dest: /etc/systemd/system/multi-user.target.wants/ceph-mon@{{ monitor_name }}.service
state: link state: link
changed_when: false changed_when: false
failed_when: false failed_when: false
@ -42,7 +42,7 @@
- name: start and add that the monitor service to the init sequence (for or after infernalis) - name: start and add that the monitor service to the init sequence (for or after infernalis)
service: service:
name: ceph-mon@{{ ansible_hostname }} name: ceph-mon@{{ monitor_name }}
state: started state: started
enabled: yes enabled: yes
changed_when: false changed_when: false
@ -51,13 +51,13 @@
is_ceph_infernalis is_ceph_infernalis
- name: collect admin and bootstrap keys - name: collect admin and bootstrap keys
command: ceph-create-keys --id {{ ansible_hostname }} command: ceph-create-keys --id {{ monitor_name }}
changed_when: false changed_when: false
failed_when: false failed_when: false
when: cephx when: cephx
- name: get ceph monitor version - name: get ceph monitor version
shell: ceph daemon mon."{{ ansible_hostname }}" version | cut -d '"' -f 4 | cut -f 1,2 -d '.' shell: ceph daemon mon."{{ monitor_name }}" version | cut -d '"' -f 4 | cut -f 1,2 -d '.'
changed_when: false changed_when: false
failed_when: "'No such file or directory' in ceph_version.stderr" failed_when: "'No such file or directory' in ceph_version.stderr"
register: ceph_version register: ceph_version