Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephadm: Refactor bootstrap.yml #18

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions roles/cephadm/tasks/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,5 @@
become: true
when: not cephadm_check_ceph_conf.stat.exists

- name: Set public network
command:
cmd: "cephadm shell -- ceph config set global public_network {{ cephadm_public_network }}"
become: true

- name: Set cluster network
command:
cmd: "cephadm shell -- ceph config set global cluster_network {{ cephadm_cluster_network }}"
when: cephadm_cluster_network | length > 0
become: true

- name: Get cluster fsid
command:
cmd: "cephadm shell -- ceph fsid"
when: cephadm_fsid | length == 0
become: true
register: cephadm_fsid_current

- name: Template out cluster.yml
vars:
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
template:
src: "templates/cluster.yml.j2"
dest: "/var/run/ceph/{{ fsid }}/cephadm_cluster.yml"
owner: root
group: root
mode: 0644
become: true
run_once: True

- name: Apply spec
command:
cmd: >
cephadm shell --
ceph orch apply -i /var/run/ceph/cephadm_cluster.yml
become: true

- name: Install ceph cli on mon hosts
command:
cmd: "cephadm install ceph"
become: true
when: cephadm_install_ceph_cli

delegate_to: "{{ groups['mons'][0] }}"
run_once: True
38 changes: 38 additions & 0 deletions roles/cephadm/tasks/cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Deploy Ceph cluster
block:
- name: Get cluster fsid
command:
cmd: "cephadm shell -- ceph fsid"
when: cephadm_fsid | length == 0
changed_when: false
become: true
register: cephadm_fsid_current

- name: Template out cluster.yml
vars:
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
template:
src: "templates/cluster.yml.j2"
dest: "/var/run/ceph/{{ fsid }}/cephadm_cluster.yml"
owner: root
group: root
mode: 0644
become: true
run_once: True

- name: Apply spec
command:
cmd: >
cephadm shell --
ceph orch apply -i /var/run/ceph/cephadm_cluster.yml
become: true

- name: Install ceph cli on mon hosts
command:
cmd: "cephadm install ceph"
become: true
when: cephadm_install_ceph_cli

delegate_to: "{{ groups['mons'][0] }}"
run_once: True
16 changes: 16 additions & 0 deletions roles/cephadm/tasks/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Configure Ceph
block:
- name: Set public network
command:
cmd: "cephadm shell -- ceph config set global public_network {{ cephadm_public_network }}"
become: true

- name: Set cluster network
command:
cmd: "cephadm shell -- ceph config set global cluster_network {{ cephadm_cluster_network }}"
when: cephadm_cluster_network | length > 0
become: true

delegate_to: "{{ groups['mons'][0] }}"
run_once: True
10 changes: 7 additions & 3 deletions roles/cephadm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
- include_tasks: "prechecks.yml"
when: not cephadm_skip_prechecks | bool

- include_tasks: "pkg_{{ ansible_os_family | lower }}.yml"
- import_tasks: "pkg_{{ ansible_os_family | lower }}.yml"
cityofships marked this conversation as resolved.
Show resolved Hide resolved

- include_tasks: "prereqs.yml"
- import_tasks: "prereqs.yml"

- include_tasks: "bootstrap.yml"
when: cephadm_bootstrap | bool

- include_tasks: "osds.yml"
- import_tasks: "config.yml"

- import_tasks: "cluster.yml"

- import_tasks: "osds.yml"
47 changes: 24 additions & 23 deletions roles/cephadm/tasks/osds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,33 @@
when: cephadm_osd_devices | length > 0
with_items: "{{ cephadm_osd_devices }}"

- name: Get cluster fsid
command:
cmd: "cephadm shell -- ceph fsid"
when: cephadm_fsid | length == 0
become: true
register: cephadm_fsid_current
- block:
- name: Get cluster fsid
command:
cmd: "cephadm shell -- ceph fsid"
when: cephadm_fsid | length == 0
changed_when: false
become: true
register: cephadm_fsid_current

- name: Template out osd_spec.yml
vars:
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
copy:
content: "{{ cephadm_osd_spec | to_nice_yaml(indent=2) }}"
dest: "/var/run/ceph/{{ fsid }}/osd_spec.yml"
owner: root
group: root
mode: 0644
when: cephadm_osd_spec | length > 0
become: true
- name: Template out osd_spec.yml
vars:
fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
copy:
content: "{{ cephadm_osd_spec | to_nice_yaml(indent=2) }}"
dest: "/var/run/ceph/{{ fsid }}/osd_spec.yml"
owner: root
group: root
mode: 0644
become: true

- name: Apply OSDs spec
command:
cmd: >
cephadm shell --
ceph orch apply osd -i /var/run/ceph/osd_spec.yml
- name: Apply OSDs spec
command:
cmd: >
cephadm shell --
ceph orch apply osd -i /var/run/ceph/osd_spec.yml
become: true
when: cephadm_osd_spec | length > 0
become: true

delegate_to: "{{ groups['mons'][0] }}"
run_once: True