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

WIP - DRAFT Move to collection ceph.automation usage #303

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[defaults]
log_path = $HOME/ansible/ansible.log
library = ./library
module_utils = ./module_utils
roles_path = ./

forks = 20
Expand Down
6 changes: 3 additions & 3 deletions ceph_defaults/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
ceph_origin: community
ceph_dev_branch: main
ceph_dev_sha1: latest
ceph_rhcs_version: 5
ceph_ibm_version: 5
ceph_rhcs_version: 8
ceph_ibm_version: 8
ceph_mirror: https://download.ceph.com
ceph_stable_key: https://download.ceph.com/keys/release.asc
ceph_community_repo_baseurl: "{{ ceph_mirror }}/rpm-{{ ceph_release }}/el{{ ansible_facts['distribution_major_version'] }}/"
ceph_ibm_repo_baseurl: "https://public.dhe.ibm.com/ibmdl/export/pub/storage/ceph/{{ ceph_ibm_version }}/rhel{{ ansible_facts['distribution_major_version'] }}/"
ceph_ibm_key: https://public.dhe.ibm.com/ibmdl/export/pub/storage/ceph/RPM-GPG-KEY-IBM-CEPH
ceph_release: quincy
ceph_release: squid
upgrade_ceph_packages: false
ceph_pkgs:
- cephadm
Expand Down
4 changes: 2 additions & 2 deletions ceph_defaults/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ galaxy_info:
author: Guillaume Abrioux
description: Handles ceph-ansible default vars for all roles
license: Apache
min_ansible_version: 2.10
min_ansible_version: 2.15
platforms:
- name: Ubuntu
versions:
- bionic
- name: EL
versions:
- 8
- 9
galaxy_tags:
- system
dependencies: []
76 changes: 38 additions & 38 deletions cephadm-clients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@
- run_once: true
delegate_to: localhost
block:
- name: import_role ceph_defaults
import_role:
- name: Import_role ceph_defaults
ansible.builtin.import_role:
name: ceph_defaults

- name: fail if the fsid parameter is missing
fail:
- name: Fail if the fsid parameter is missing
ansible.builtin.fail:
msg: >
You must supply an 'fsid' parameter for the corresponding ceph cluster
when: fsid is undefined

- name: fail if admin group doesn't exist or is empty
fail:
- name: Fail if admin group doesn't exist or is empty
ansible.builtin.fail:
msg: |
You must define a group [admin] in your inventory which provides the
keyring that you want to distribute
when: "'admin' not in groups or groups['admin'] | length < 1"

- name: fail if client_group is NOT in the inventory
fail:
- name: Fail if client_group is NOT in the inventory
ansible.builtin.fail:
msg: >
Variable client_group '{{ client_group }}' is not defined in the inventory
when: client_group not in groups

- name: fail if keyring variable is missing
fail:
- name: Fail if keyring variable is missing
ansible.builtin.fail:
msg: |
You must supply a 'keyring' variable that defines the path to the key
that you want to distribute to your client machines
Expand All @@ -69,38 +69,38 @@
gather_facts: false
tasks:

- name: check fsid is present on {{ inventory_hostname }}
stat:
- name: Check fsid is present on {{ inventory_hostname }}
ansible.builtin.stat:
path: /var/lib/ceph/{{ fsid }}
register: fsid_stat

- name: fail if fsid is not present
fail:
- name: Fail if fsid is not present
ansible.builtin.fail:
msg: >
The given fsid ({{ fsid }}), is not present in /var/lib/ceph on {{ inventory_hostname }}
when:
- not fsid_stat.stat.exists | bool
- not fsid_stat.stat.isdir | bool

- name: check keyring status on {{ inventory_hostname }}
stat:
- name: Check keyring status on {{ inventory_hostname }}
ansible.builtin.stat:
path: "{{ keyring }}"
register: keyring_stat

- name: fail if keyring not found on {{ inventory_hostname }}
fail:
- name: Fail if keyring not found on {{ inventory_hostname }}
ansible.builtin.fail:
msg: >
The keyring path provided '{{ keyring }}' can not be found on {{ inventory_hostname }}
when: not keyring_stat.stat.exists | bool

- name: check conf is OK to use
stat:
- name: Check conf is OK to use
ansible.builtin.stat:
path: "{{ conf }}"
register: conf_stat
when: conf is defined

- name: fail if conf supplied is not on {{ inventory_hostname }}
fail:
- name: Fail if conf supplied is not on {{ inventory_hostname }}
ansible.builtin.fail:
msg: |
The conf file '{{ conf }}' can not be found on {{ inventory_hostname }}
when:
Expand All @@ -115,26 +115,26 @@
gather_facts: false
tasks:

- name: import_role ceph_defaults
import_role:
- name: Import_role ceph_defaults
ansible.builtin.import_role:
name: ceph_defaults

- name: slurp the keyring
slurp:
- name: Slurp the keyring
ansible.builtin.slurp:
src: "{{ keyring }}"
register: client_keyring
no_log: true

- name: slurp the conf if it's supplied
slurp:
- name: Slurp the conf if it's supplied
ansible.builtin.slurp:
src: "{{ conf }}"
register: ceph_config
when:
- conf is defined
- conf | length > 0

- name: create minimal conf as a default
command: cephadm shell -- ceph config generate-minimal-conf
- name: Create minimal conf as a default
ansible.builtin.command: cephadm shell -- ceph config generate-minimal-conf
register: minimal_ceph_config
when: conf is undefined

Expand All @@ -145,26 +145,26 @@
gather_facts: true
tasks:

- name: import_role ceph_defaults
import_role:
- name: Import_role ceph_defaults
ansible.builtin.import_role:
name: ceph_defaults

- name: install ceph-common on rhel
command: dnf install --allowerasing --assumeyes ceph-common
- name: Install ceph-common on rhel
ansible.builtin.command: dnf install --allowerasing --assumeyes ceph-common
changed_when: false
register: result
until: result is succeeded
when: ansible_facts['os_family'] == 'RedHat'

- name: install ceph client prerequisites if needed
package:
- name: Install ceph client prerequisites if needed
ansible.builtin.package:
name: "{{ ceph_client_pkgs }}"
state: present
register: result
until: result is succeeded

- name: copy configuration and keyring files to the clients
copy:
- name: Copy configuration and keyring files to the clients
ansible.builtin.copy:
content: "{{ item.content }}"
dest: "{{ item.dest }}"
owner: ceph
Expand Down
26 changes: 13 additions & 13 deletions cephadm-distribute-ssh-key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,47 @@
become: true
gather_facts: false
tasks:
- name: fail if admin_node is not defined
fail:
- name: Fail if admin_node is not defined
ansible.builtin.fail:
msg: "You must set the variable admin_node"
run_once: true
delegate_to: localhost
when: admin_node is undefined

- name: get ssh public key from a file on the Ansible controller host
- name: Get ssh public key from a file on the Ansible controller host
when: cephadm_pubkey_path is defined
block:
- name: get details about {{ cephadm_pubkey_path }}
stat:
- name: Get details about {{ cephadm_pubkey_path }}
ansible.builtin.stat:
path: "{{ cephadm_pubkey_path }}"
register: cephadm_pubkey_path_stat
delegate_to: localhost
run_once: true

- name: fail if {{ cephadm_pubkey_path }} doesn't exist
fail:
- name: Fail if {{ cephadm_pubkey_path }} doesn't exist
ansible.builtin.fail:
msg: "{{ cephadm_pubkey_path }} doesn't exist or is invalid."
run_once: true
delegate_to: localhost
when:
- not cephadm_pubkey_path_stat.stat.exists | bool
or not cephadm_pubkey_path_stat.stat.isfile | bool

- name: get the cephadm ssh pub key
command: "cephadm shell {{ '--fsid ' + fsid if fsid is defined else '' }} ceph cephadm get-pub-key"
- name: Get the cephadm ssh pub key
ansible.builtin.command: "cephadm shell {{ '--fsid ' + fsid if fsid is defined else '' }} ceph cephadm get-pub-key"
changed_when: false
run_once: true
register: cephadm_get_pub_key
delegate_to: "{{ admin_node }}"
when: cephadm_pubkey_path is undefined

- name: allow ssh public key for {{ cephadm_ssh_user | default('root') }} account
authorized_key:
- name: Allow ssh public key for {{ cephadm_ssh_user | default('root') }} account
ansible.posix.authorized_key:
user: "{{ cephadm_ssh_user | default('root') }}"
key: "{{ lookup('file', cephadm_pubkey_path) if cephadm_pubkey_path is defined else cephadm_get_pub_key.stdout }}"

- name: set cephadm ssh user to {{ cephadm_ssh_user }}
command: "cephadm shell {{ '--fsid ' + fsid if fsid is defined else '' }} ceph cephadm set-user {{ cephadm_ssh_user | default('root') }}"
- name: Set cephadm ssh user to {{ cephadm_ssh_user }}
ansible.builtin.command: "cephadm shell {{ '--fsid ' + fsid if fsid is defined else '' }} ceph cephadm set-user {{ cephadm_ssh_user | default('root') }}"
changed_when: false
run_once: true
delegate_to: "{{ admin_node }}"
Loading
Loading