]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-mon/mds: fix fqdn 599/head
authorSébastien Han <seb@redhat.com>
Thu, 3 Mar 2016 10:03:03 +0000 (11:03 +0100)
committerSébastien Han <seb@redhat.com>
Thu, 3 Mar 2016 20:23:14 +0000 (21:23 +0100)
closes #596

Signed-off-by: Sébastien Han <seb@redhat.com>
roles/ceph-common/handlers/main.yml
roles/ceph-common/templates/ceph.conf.j2
roles/ceph-mds/tasks/pre_requisite.yml
roles/ceph-mon/tasks/deploy_monitors.yml
roles/ceph-mon/tasks/start_monitor.yml

index 8aa7cc44837fcc42e683d2cbecd89823db534fa4..9b166b567e0e52a8d2facdf52afcb1ee5face0d6 100644 (file)
@@ -13,7 +13,7 @@
 
 - name: restart ceph mons with systemd
   service:
-      name: ceph-mon@{{ ansible_hostname }}
+      name: ceph-mon@{{ monitor_name }}
       state: restarted
   when:
     socket.rc == 0 and
@@ -74,7 +74,7 @@
 
 - name: restart ceph mdss with systemd
   service:
-      name: ceph-mds@{{ ansible_hostname }}
+      name: ceph-mds@{{ mds_name }}
       state: restarted
   when:
     socket.rc == 0 and
index 7752248e2df2216cdea6d77c4e68c6038e9b2c76..c5d154a3ee6ec588801733a9b175593e476336ba 100644 (file)
@@ -93,7 +93,7 @@ debug auth = {{ debug_mon_level }}
 [mon.{{ 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'] }}
-{% else %}
+{% elif hostvars[host]['ansible_hostname'] is defined %}
 [mon.{{ 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'] }}
@@ -155,18 +155,18 @@ osd deep scrub stride = {{ osd_deep_scrub_stride }}
 {% if hostvars[host]['ansible_fqdn'] is defined and mds_use_fqdn %}
 [mds.{{ hostvars[host]['ansible_fqdn'] }}]
 host = {{ hostvars[host]['ansible_fqdn'] }}
-{% else %}
+{% elif hostvars[host]['ansible_hostname'] is defined %}
 [mds.{{ hostvars[host]['ansible_hostname'] }}]
 host = {{ hostvars[host]['ansible_hostname'] }}
 {% endif %}
 {% endfor %}
+{% endif %}
 {% if enable_debug_mds %}
 debug mds = {{ debug_mds_level }}
 debug mds balancer = {{ debug_mds_level }}
 debug mds log = {{ debug_mds_level }}
 debug mds migrator = {{ debug_mds_level }}
 {% endif %}
-{% endif %}
 
 {% if groups[rgw_group_name] is defined %}
 {% for host in groups[rgw_group_name] %}
index ede48415abebe2f66cdd2dfbcb9b62ae3cfa8b8e..dabfbafa2d946076b6dbd15d221312a79b355ff0 100644 (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
   file:
     path: /var/lib/ceph/bootstrap-mds/
 
 - name: create mds directory
   file:
-    path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}
+    path: /var/lib/ceph/mds/ceph-{{ mds_name }}
     state: directory
     owner: "{{ dir_owner }}"
     group: "{{ dir_group }}"
     mode: "{{ dir_mode }}"
 
 - 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:
-    creates: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring
+    creates: /var/lib/ceph/mds/ceph-{{ mds_name }}/keyring
   changed_when: false
   when: cephx
 
 - name: set mds key permissions
   file:
-    path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring
+    path: /var/lib/ceph/mds/ceph-{{ mds_name }}/keyring
     mode: "{{ key_mode }}"
     owner: "{{ key_owner }}"
     group: "{{ key_group }}"
@@ -46,7 +54,7 @@
 
 - name: activate metadata server with upstart
   file:
-    path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/{{ item }}
+    path: /var/lib/ceph/mds/ceph-{{ mds_name }}/{{ item }}
     state: touch
     owner: "{{ activate_file_owner }}"
     group: "{{ activate_file_group }}"
@@ -59,7 +67,7 @@
 
 - name: activate metadata server with sysvinit
   file:
-    path: /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/{{ item }}
+    path: /var/lib/ceph/mds/ceph-{{ mds_name }}/{{ item }}
     state: touch
     owner: "{{ activate_file_owner }}"
     group: "{{ activate_file_group }}"
@@ -73,7 +81,7 @@
 - name: enable systemd unit file for mds instance (for or after infernalis)
   file:
     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
   changed_when: false
   failed_when: false
@@ -86,7 +94,7 @@
     name: ceph-mds
     state: started
     enabled: yes
-    args: "id={{ ansible_hostname }}"
+    args: "id={{ mds_name }}"
   changed_when: false
   when: ansible_distribution == "Ubuntu"
 
     name: ceph
     state: started
     enabled: yes
-    args: mds.{{ ansible_hostname }}
+    args: mds.{{ mds_name }}
   changed_when: false
   when:
     ansible_distribution != "Ubuntu" and
 
 - name: start and add that the metadata service to the init sequence (for or after infernalis)
   service:
-    name: ceph-mds@{{ ansible_hostname }}
+    name: ceph-mds@{{ mds_name }}
     state: started
     enabled: yes
   changed_when: false
index 7c0df01ff3e48895fb4435e22f14ec9890e6bc1a..eb36a8c93b0a9db9f69eb9d14cd7bdc337c53f10 100644 (file)
   become: false
   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
-  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:
-    creates: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
+    creates: /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
   when: cephx
 
 - name: set initial monitor key permissions
   file:
-    path: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
+    path: /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }}
     mode: "{{ key_mode }}"
     owner: "{{ key_owner }}"
     group: "{{ key_group }}"
 
 - name: create monitor directory
   file:
-    path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
+    path: /var/lib/ceph/mon/ceph-{{ monitor_name }}
     state: directory
     owner: "{{ dir_owner }}"
     group: "{{ dir_group }}"
     mode: "{{ dir_mode }}"
 
 - 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:
-    creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring
+    creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
   when:
     cephx and
     is_ceph_infernalis
 
 - 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:
-    creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/store.db
+    creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
   when:
     not cephx and
     is_ceph_infernalis
 
 - 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:
-    creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring
+    creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/keyring
   when:
     cephx and
     not is_ceph_infernalis
 
 - 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:
-    creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/store.db
+    creates: /var/lib/ceph/mon/ceph-{{ monitor_name }}/store.db
   when:
     not cephx and
     not is_ceph_infernalis
index 31db56c20716c7afea586b77bd2ee98b8ed7514e..28ce2321d94fa2f10bc9f669893b5ea6cb1fb595 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: activate monitor with upstart
   file:
-    path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/{{ item }}
+    path: /var/lib/ceph/mon/ceph-{{ monitor_name }}/{{ item }}
     state: touch
     owner: "{{ activate_file_owner }}"
     group: "{{ activate_file_group }}"
@@ -17,7 +17,7 @@
     name: ceph-mon
     state: started
     enabled: yes
-    args: "id={{ ansible_hostname }}"
+    args: "id={{ monitor_name }}"
   when: ansible_distribution == "Ubuntu"
 
 # 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)
   file:
     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
   changed_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)
   service:
-      name: ceph-mon@{{ ansible_hostname }}
+      name: ceph-mon@{{ monitor_name }}
       state: started
       enabled: yes
   changed_when: false
     is_ceph_infernalis
 
 - name: collect admin and bootstrap keys
-  command: ceph-create-keys --id {{ ansible_hostname }}
+  command: ceph-create-keys --id {{ monitor_name }}
   changed_when: false
   failed_when:  false
   when: cephx
 
 - 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
   failed_when: "'No such file or directory' in ceph_version.stderr"
   register: ceph_version