2014-09-05 03:14:11 +08:00
|
|
|
---
|
2015-05-16 00:27:41 +08:00
|
|
|
# NOTE (leseb) : this task is for disk devices only because of the explicit use of the first
|
2014-09-05 03:14:11 +08:00
|
|
|
# partition.
|
2016-02-25 06:09:34 +08:00
|
|
|
|
|
|
|
- name: automatically activate osd disk(s) without partitions
|
|
|
|
command: ceph-disk activate "/dev/{{ item.key }}"
|
|
|
|
ignore_errors: true
|
|
|
|
with_dict: ansible_devices
|
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- ansible_devices is defined
|
|
|
|
- item.value.removable == "0"
|
|
|
|
- item.value.partitions|count == 0
|
|
|
|
- journal_collocation
|
|
|
|
- osd_auto_discovery
|
2016-02-25 06:09:34 +08:00
|
|
|
|
2015-07-24 02:01:43 +08:00
|
|
|
- name: activate osd(s) when device is a disk
|
2015-10-19 09:24:47 +08:00
|
|
|
command: ceph-disk activate {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
|
2014-09-05 03:14:11 +08:00
|
|
|
with_together:
|
2016-08-17 05:49:30 +08:00
|
|
|
- "{{ ispartition_results.results }}"
|
|
|
|
- "{{ devices }}"
|
2015-06-26 06:26:03 +08:00
|
|
|
changed_when: false
|
2015-08-18 00:14:06 +08:00
|
|
|
failed_when: false
|
2016-04-11 22:28:03 +08:00
|
|
|
register: activate_osd_disk
|
2016-02-25 00:25:26 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- not item.0.get("skipped")
|
|
|
|
- item.0.get("rc", 0) != 0
|
|
|
|
- not osd_auto_discovery
|
2016-07-19 23:55:57 +08:00
|
|
|
- raw_multi_journal
|
|
|
|
|
|
|
|
- name: automatically activate osd disk(s) without partitions (dmcrypt)
|
|
|
|
command: ceph-disk activate --dmcrypt "/dev/{{ item.key }}"
|
|
|
|
ignore_errors: true
|
|
|
|
with_dict: ansible_devices
|
|
|
|
when:
|
|
|
|
- ansible_devices is defined
|
|
|
|
- item.value.removable == "0"
|
|
|
|
- item.value.partitions|count == 0
|
|
|
|
- osd_auto_discovery
|
2016-08-10 16:34:23 +08:00
|
|
|
- dmcrypt_journal_collocation
|
2016-07-19 23:55:57 +08:00
|
|
|
|
|
|
|
- name: activate osd(s) when device is a disk (dmcrypt)
|
|
|
|
command: ceph-disk activate --dmcrypt {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
|
|
|
|
with_together:
|
2016-08-17 05:49:30 +08:00
|
|
|
- "{{ ispartition_results.results }}"
|
|
|
|
- "{{ devices }}"
|
2016-07-19 23:55:57 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
register: activate_osd_disk_dmcrypt
|
|
|
|
when:
|
|
|
|
- not item.0.get("skipped")
|
|
|
|
- item.0.get("rc", 0) != 0
|
|
|
|
- not osd_auto_discovery
|
|
|
|
- dmcrypt_dedicated_journal
|
|
|
|
|
|
|
|
# NOTE (leseb): we must do this because of
|
|
|
|
# https://github.com/ansible/ansible/issues/4297
|
|
|
|
- name: combine ispartition results
|
|
|
|
set_fact:
|
2016-08-10 16:34:23 +08:00
|
|
|
combined_activate_osd_disk_results: "{{ activate_osd_disk if not dmcrypt_journal_collocation else activate_osd_disk_dmcrypt }}"
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2016-04-11 22:28:03 +08:00
|
|
|
- name: fail if ceph-disk cannot create an OSD
|
|
|
|
fail:
|
|
|
|
msg: "ceph-disk failed to create an OSD"
|
|
|
|
when:
|
|
|
|
" 'ceph-disk: Error: ceph osd create failed' in item.get('stderr', '') "
|
2016-10-03 22:48:04 +08:00
|
|
|
with_items: "{{ (combined_activate_osd_disk_results|default({})).results|default([]) }}"
|
2016-04-11 22:28:03 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
# NOTE (leseb): this task is for partitions because we don't explicitly use a partition.
|
2015-07-24 02:01:43 +08:00
|
|
|
- name: activate osd(s) when device is a partition
|
2014-09-05 03:14:11 +08:00
|
|
|
command: "ceph-disk activate {{ item.1 }}"
|
|
|
|
with_together:
|
2016-08-17 05:49:30 +08:00
|
|
|
- "{{ ispartition_results.results }}"
|
|
|
|
- "{{ devices }}"
|
2015-06-26 06:26:03 +08:00
|
|
|
changed_when: false
|
2015-07-29 00:21:15 +08:00
|
|
|
failed_when: false
|
2016-02-25 00:25:26 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- not item.0.get("skipped")
|
|
|
|
- item.0.get("rc", 0) == 0
|
|
|
|
- not osd_auto_discovery
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2015-01-09 01:27:43 +08:00
|
|
|
- include: osd_fragment.yml
|
|
|
|
when: crush_location
|
|
|
|
|
2016-03-11 17:25:25 +08:00
|
|
|
- name: set selinux to permissive and make it persistent
|
|
|
|
selinux:
|
|
|
|
policy: targeted
|
|
|
|
state: permissive
|
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- ansible_selinux != false
|
|
|
|
- ansible_selinux['status'] == 'enabled'
|
|
|
|
- ansible_selinux['config_mode'] != 'disabled'
|
2016-09-10 06:16:41 +08:00
|
|
|
- ceph_release_num.{{ ceph_release }} < ceph_release_num.infernalis
|
2016-03-11 17:25:25 +08:00
|
|
|
|
2015-11-21 05:34:29 +08:00
|
|
|
- name: start and add that the osd service(s) to the init sequence (before infernalis)
|
2015-10-19 09:24:47 +08:00
|
|
|
service:
|
|
|
|
name: ceph
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2015-11-21 05:34:29 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- ansible_distribution != "Ubuntu"
|
2016-09-10 06:16:41 +08:00
|
|
|
- ceph_release_num.{{ ceph_release }} < ceph_release_num.infernalis
|
2015-11-21 05:34:29 +08:00
|
|
|
|
2016-01-13 04:41:51 +08:00
|
|
|
- name: get osd id (for or after infernalis)
|
2016-05-29 15:20:46 +08:00
|
|
|
shell: 'ls /var/lib/ceph/osd/ | grep -oP "\d+$"'
|
2016-01-13 04:41:51 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
register: osd_id
|
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- use_systemd
|
2016-09-10 06:16:41 +08:00
|
|
|
- ceph_release_num.{{ ceph_release }} > ceph_release_num.hammer
|
2016-01-13 04:41:51 +08:00
|
|
|
|
2016-05-14 02:19:29 +08:00
|
|
|
- name: enable the osd service (for or after infernalis)
|
|
|
|
command: systemctl enable ceph-osd@{{ item }}
|
|
|
|
changed_when: false
|
2016-01-13 04:41:51 +08:00
|
|
|
failed_when: false
|
2016-10-03 22:48:04 +08:00
|
|
|
with_items: "{{ (osd_id|default({})).stdout_lines|default([]) }}"
|
2016-01-13 04:41:51 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- use_systemd
|
2016-09-10 06:16:41 +08:00
|
|
|
- ceph_release_num.{{ ceph_release }} > ceph_release_num.hammer
|
2016-01-13 04:41:51 +08:00
|
|
|
|
2015-11-20 22:09:34 +08:00
|
|
|
- name: start and add that the osd service(s) to the init sequence (for or after infernalis)
|
2015-11-21 05:34:29 +08:00
|
|
|
service:
|
2016-01-13 04:41:51 +08:00
|
|
|
name: ceph-osd@{{ item }}
|
2015-11-21 05:34:29 +08:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
2016-10-03 22:48:04 +08:00
|
|
|
with_items: "{{ (osd_id|default({})).stdout_lines|default([]) }}"
|
2016-01-13 04:41:51 +08:00
|
|
|
changed_when: false
|
2015-11-21 05:34:29 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- use_systemd
|
2016-09-10 06:16:41 +08:00
|
|
|
- ceph_release_num.{{ ceph_release }} > ceph_release_num.hammer
|