]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/log
ceph-ansible.git
4 years agomain: add tags on each play guits-single2multisite 6121/head
Guillaume Abrioux [Thu, 10 Dec 2020 17:08:24 +0000 (18:08 +0100)]
main: add tags on each play

wip

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agorhcs: drop fetch_directory override
Dimitri Savineau [Wed, 2 Dec 2020 22:45:18 +0000 (17:45 -0500)]
rhcs: drop fetch_directory override

Since the fetch_directory variable has been dropped then we don't need
the override in rhcs file.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoceph-mon: No become during gen mon initial keyring
Jukka Nousiainen [Wed, 2 Dec 2020 09:07:25 +0000 (11:07 +0200)]
ceph-mon: No become during gen mon initial keyring

Since the backing generate_secret() just hands out urandom output,
running as privileged doesn't seem to be required. It's not
desireable to provide sudo in some Ansible runner environments.

Signed-off-by: Jukka Nousiainen <jukka.nousiainen@csc.fi>
4 years agolibrary: add cephadm_adopt module
Dimitri Savineau [Mon, 30 Nov 2020 19:32:54 +0000 (14:32 -0500)]
library: add cephadm_adopt module

This adds cephadm_adopt ansible module for replacing the command module
usage with the cephadm adopt command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agocommon: do not use pipefail when not needed
Guillaume Abrioux [Mon, 30 Nov 2020 16:08:18 +0000 (17:08 +0100)]
common: do not use pipefail when not needed

Let's discard the ansible lint error 306 and add a "# noqa 306" on tasks
where we don't need `set -o pipefail`

Fixes: #6090
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoconsume ceph_volume module when possible
Dimitri Savineau [Wed, 18 Nov 2020 22:20:45 +0000 (17:20 -0500)]
consume ceph_volume module when possible

We should always use the ceph_volume ansible module when possible.
This patch replace the ceph-volume inventory and lvm {list,zap} commands
called via the command/shell modules by the corresponding call with the
ceph_volume module.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add ceph_crush_rule module
Dimitri Savineau [Mon, 9 Nov 2020 17:16:41 +0000 (12:16 -0500)]
library: add ceph_crush_rule module

This adds ceph_crush_rule ansible module for replacing the command
module usage with the ceph osd crush rule commands.
This module can manage both erasure and replicated crush rules.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoosd: add tag on 'wait for all osd to be up' task
Guillaume Abrioux [Thu, 26 Nov 2020 08:53:04 +0000 (09:53 +0100)]
osd: add tag on 'wait for all osd to be up' task

This allows skipping this task if really desired.
Use it carefully. Use it at your own risk.

Fixes: #6073
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-client: use group_by instead of add_host
Dimitri Savineau [Mon, 30 Nov 2020 17:15:48 +0000 (12:15 -0500)]
ceph-client: use group_by instead of add_host

Instead of iterate over all client nodes with a loop sequentially, we
can use the group_by ansible buildin.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add cephadm_bootstrap module
Dimitri Savineau [Fri, 16 Oct 2020 00:42:00 +0000 (20:42 -0400)]
library: add cephadm_bootstrap module

This adds cephadm_bootstrap ansible module for replacing the command module
usage with the cephadm bootstrap command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add ceph_osd_flag module
Dimitri Savineau [Tue, 3 Nov 2020 21:44:58 +0000 (16:44 -0500)]
library: add ceph_osd_flag module

This adds ceph_osd_flag ansible module for replacing the command module
usage with the ceph osd set/unset commands.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoiscsigw: remove `--cap-add=all` from `podman run` cmd
Guillaume Abrioux [Mon, 30 Nov 2020 13:55:16 +0000 (14:55 +0100)]
iscsigw: remove `--cap-add=all` from `podman run` cmd

As of podman `2.0.5`, `--cap-add` and `--privileged` are exclusive
options.

```
Nov 30 13:56:30 magna089 podman[171677]: Error: invalid config provided: CapAdd and privileged are mutually exclusive options
```

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1902149
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agocontainer: remove `--ignore` from `podman rm` command
Guillaume Abrioux [Mon, 30 Nov 2020 13:52:47 +0000 (14:52 +0100)]
container: remove `--ignore` from `podman rm` command

As of podman 2.0.5, `--ignore` param conflicts with `--storage`.
```
Nov 30 13:53:10 magna089 podman[164443]: Error: --storage conflicts with --volumes, --all, --latest, --ignore and --cidfile
```

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: add ceph_osd module
Dimitri Savineau [Fri, 20 Nov 2020 22:50:59 +0000 (17:50 -0500)]
library: add ceph_osd module

This adds ceph_osd ansible module for replacing the command module
usage with the ceph osd destroy/down/in/out/purge/rm commands.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add ceph_mgr_module module
Dimitri Savineau [Mon, 16 Nov 2020 15:11:20 +0000 (10:11 -0500)]
library: add ceph_mgr_module module

This adds ceph_mgr_module ansible module for replacing the command module
usage with the ceph mgr module enable/disable commands.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agotests: use ca_test_common with ceph_volume_simple
Dimitri Savineau [Fri, 27 Nov 2020 20:21:13 +0000 (15:21 -0500)]
tests: use ca_test_common with ceph_volume_simple

To avoid duplicate code.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoimprove plugins/filter testing
Dimitri Savineau [Fri, 27 Nov 2020 17:25:11 +0000 (12:25 -0500)]
improve plugins/filter testing

- The plugins/filter directory wasn't present in the flake8 workflow
configuration.
- Fix the flake8 syntax.
- Add the directory to PYTHONPATH environment variable for pytest
to avoid importing the plugin filter via sys.
- Add unittest on missing netaddr module import.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoswitch2containers: do not stop ceph.target in osd play
Guillaume Abrioux [Thu, 26 Nov 2020 09:11:36 +0000 (10:11 +0100)]
switch2containers: do not stop ceph.target in osd play

`ceph.target` should be disabled only. Otherwise, in collocation
scenario you stop other collocated services in the OSD play which isn't
what we want to do. Each daemon has its corresponding play for managing
the transition to container.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1901865
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoalertmanager/prometheus: fix owner/group
Dimitri Savineau [Wed, 25 Nov 2020 17:00:38 +0000 (12:00 -0500)]
alertmanager/prometheus: fix owner/group

Set the owner/group on alertmanager and prometheus directories and
files to nobody and nogroup (uid and gid 65534) to avoid permission
issues.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1901543
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agotests: add module_utils directory to flake8/pytest
Dimitri Savineau [Thu, 26 Nov 2020 19:59:29 +0000 (14:59 -0500)]
tests: add module_utils directory to flake8/pytest

This adds the module_utils and associated test directory into the flake8
and pytest workflow configuration.
It also moves the ca_common module_utils test file from tests/library to
it's own directory tests/module_utils.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agomodule_utils: refactor
Guillaume Abrioux [Wed, 25 Nov 2020 19:51:09 +0000 (20:51 +0100)]
module_utils: refactor

- update `generate_ceph_cmd()` so `user_key` is automatically built from
`cluster` and `user` params.

- update and add testing.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: use exit_module from ca_common
Guillaume Abrioux [Wed, 25 Nov 2020 09:18:56 +0000 (10:18 +0100)]
library: use exit_module from ca_common

pr #6054 got merged but could have been updated to use `ca_common` for
`exit_module()`

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agorhcs: default to containerized deployment
Dimitri Savineau [Fri, 10 Jul 2020 14:36:02 +0000 (10:36 -0400)]
rhcs: default to containerized deployment

Starting RHCS 5, only containerized deployment is available.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: remove useless condition in ceph_volume
Dimitri Savineau [Tue, 24 Nov 2020 20:14:52 +0000 (15:14 -0500)]
library: remove useless condition in ceph_volume

Since the action values are already defined as a list of choices in
ansible then we will never enter into this condition.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add ceph_volume_simple_{activate,scan}
Dimitri Savineau [Tue, 17 Nov 2020 14:22:34 +0000 (09:22 -0500)]
library: add ceph_volume_simple_{activate,scan}

This adds ceph_volume_simple_{activate,scan} ansible modules for replacing
the command module usage with the ceph-volume simple activate/scan commands.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agomon: refact initial keyring generation
Guillaume Abrioux [Tue, 24 Nov 2020 10:33:46 +0000 (11:33 +0100)]
mon: refact initial keyring generation

adding monitor is no longer possible because we generate a new mon
keyring each time the playbook is run.

Fixes: #5864
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agomon: replace `command` task by `copy`
Guillaume Abrioux [Tue, 24 Nov 2020 11:56:04 +0000 (12:56 +0100)]
mon: replace `command` task by `copy`

We can achieve this task using `copy` module.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-iscsi: set the pool name in the config file
Dimitri Savineau [Tue, 24 Nov 2020 17:35:23 +0000 (12:35 -0500)]
ceph-iscsi: set the pool name in the config file

When using a custom pool for iSCSI gateway then we need to set the pool
name in the configuration otherwise the default rbd pool name will be
used.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agotests: update pytest workflow
Guillaume Abrioux [Mon, 23 Nov 2020 08:00:01 +0000 (09:00 +0100)]
tests: update pytest workflow

This sets the `PYTHONPATH` environment variable so we can run pytest
with the recent module refactor (module_utils introduction)

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: import ca_test_common in test_ceph_key
Guillaume Abrioux [Mon, 9 Nov 2020 14:57:14 +0000 (15:57 +0100)]
library: import ca_test_common in test_ceph_key

since we added `ca_test_common.py` let's use it in `test_ceph_key.py`

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agorgw: call `ceph_ec_profile` when needed
Guillaume Abrioux [Thu, 5 Nov 2020 13:59:33 +0000 (14:59 +0100)]
rgw: call `ceph_ec_profile` when needed

Let's replace `command` tasks with `ceph_ec_profile` calls

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: add ec_profile module
Guillaume Abrioux [Thu, 5 Nov 2020 13:52:47 +0000 (14:52 +0100)]
library: add ec_profile module

This commit adds a new module `ceph_ec_profile` to manage erasure code
profiles.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: add module_utils namespace
Guillaume Abrioux [Thu, 5 Nov 2020 10:05:34 +0000 (11:05 +0100)]
library: add module_utils namespace

This adds a new `module_utils` namespace in order to avoid defining same
functions in each module.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agotests: use github workflow for nbsp char check
Guillaume Abrioux [Thu, 19 Nov 2020 08:13:28 +0000 (09:13 +0100)]
tests: use github workflow for nbsp char check

Let's use a github workflow instead of travis for this.

With this commit we can get rid of Travis.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: ignore 302,303,505 errors
Guillaume Abrioux [Wed, 18 Nov 2020 09:13:45 +0000 (10:13 +0100)]
lint: ignore 302,303,505 errors

ignore 302,303 and 505 errors

[302] Using command rather than an argument to e.g. file
[303] Using command rather than module
[505] referenced files must exist

they aren't relevant on these tasks.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: do not use 'local_action'
Guillaume Abrioux [Fri, 2 Oct 2020 11:43:47 +0000 (13:43 +0200)]
lint: do not use 'local_action'

Fix ansible-lint 504 error:

[504] Do not use 'local_action', use 'delegate_to: localhost'

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: trailing whitespace
Guillaume Abrioux [Fri, 2 Oct 2020 11:40:31 +0000 (13:40 +0200)]
lint: trailing whitespace

Fix ansible-lint 201 error:

[201] Trailing whitespace

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: all tasks should be named
Guillaume Abrioux [Fri, 2 Oct 2020 11:38:04 +0000 (13:38 +0200)]
lint: all tasks should be named

Fix ansible-lint 502 error:

[502] All tasks should be named

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: use shell only when shell functionality is required
Guillaume Abrioux [Fri, 2 Oct 2020 11:35:39 +0000 (13:35 +0200)]
lint: use shell only when shell functionality is required

Fix ansible-lint 305 error:

[305] Use shell only when shell functionality is required

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: don't compare to literal true/false
Guillaume Abrioux [Fri, 2 Oct 2020 11:32:51 +0000 (13:32 +0200)]
lint: don't compare to literal true/false

Fix ansible lint 601 error:

[601] Don't compare to literal True/False

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: variables should have spaces before and after
Guillaume Abrioux [Fri, 2 Oct 2020 11:05:01 +0000 (13:05 +0200)]
lint: variables should have spaces before and after

Fix ansible lint 206 error:

[206] Variables should have spaces before and after: {{ var_name }}

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: commands should not change things
Guillaume Abrioux [Fri, 2 Oct 2020 10:55:53 +0000 (12:55 +0200)]
lint: commands should not change things

Fix ansible lint 301 error:

[301] Commands should not change things if nothing needs doing

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolint: set pipefail on shell tasks
Guillaume Abrioux [Fri, 2 Oct 2020 09:23:42 +0000 (11:23 +0200)]
lint: set pipefail on shell tasks

Fix ansible lint 306 error:

[306] Shells that use pipes should set the pipefail option

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agotests: use github workflow for ansible-lint
Guillaume Abrioux [Thu, 1 Oct 2020 08:23:22 +0000 (10:23 +0200)]
tests: use github workflow for ansible-lint

let's use github workflow instead of travis.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoosd: ensure /var/lib/ceph/osd/{cluster}-{id} is present
Guillaume Abrioux [Tue, 17 Nov 2020 09:45:14 +0000 (10:45 +0100)]
osd: ensure /var/lib/ceph/osd/{cluster}-{id} is present

This commit ensures that the `/var/lib/ceph/osd/{{ cluster }}-{{ osd_id }}` is
present before starting OSDs.

This is needed specificly when redeploying an OSD in case of OS upgrade
failure.
Since ceph data are still present on its devices then the node can be
redeployed, however those directories aren't present since they are
initially created by ceph-volume. We could recreate them manually but
for better user experience we can ask ceph-ansible to recreate them.

NOTE:
this only works for OSDs that were deployed with ceph-volume.
ceph-disk deployed OSDs would have to get those directories recreated
manually.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1898486
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-facts: fix read osd pool default crush fact
Dimitri Savineau [Wed, 18 Nov 2020 15:43:57 +0000 (10:43 -0500)]
ceph-facts: fix read osd pool default crush fact

We don't need to use run_once on that task when having running monitors
otherwise the read task could be skip and the set task will fail.

The conditional check 'crush_rule_variable.rc == 0' failed. The error
was: error while evaluating conditional (crush_rule_variable.rc == 0):
'dict object' has no attribute 'rc'

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1898856
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agotests: use github workflow for pytest
Dimitri Savineau [Fri, 23 Oct 2020 14:24:50 +0000 (10:24 -0400)]
tests: use github workflow for pytest

Move the pytest testing from TravisCI to Github workflow.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agocontainers: modify bindmount option
Guillaume Abrioux [Tue, 17 Nov 2020 03:35:27 +0000 (04:35 +0100)]
containers: modify bindmount option

This commit changes the bind mount option for the mount point
`/var/lib/ceph` in the systemd template for mon and mgr containers. This
is needed in case of collocating mon/mgr with osds using dmcrypt
scenario.
Once mon/mgr got converted to containers, the dmcrypt layer sub mount is
still seen in `/var/lib/ceph`. For some reason it makes the
corresponding devices busy so any other container can't open/close it.
As a result, it prevents osds from starting properly.

Since it only happens on the nodes converted before the OSD play, the idea is
to bind mount `/var/lib/ceph` on mon and mgr with the `rshared` option
so once the sub mount is unmounted, it is propagated inside the
container so it doesn't see that mount point.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1896392
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoswitch2container: chown symlink in mon/mgr plays
Dimitri Savineau [Mon, 16 Nov 2020 15:31:11 +0000 (10:31 -0500)]
switch2container: chown symlink in mon/mgr plays

fa2bb3a only fix the symlink owner/group issue in the OSD play. If the
OSDs are collocated with other services like MONs and MGRs then the
chown command will fail.

$ find /var/lib/ceph/osd/ceph-0 -not -user 167 -execdir chown 167:167 {} +
chown: cannot dereference './block': Permission denied

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1896448
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agocontainer: force rm --storage on ExecStartPre
Guillaume Abrioux [Thu, 12 Nov 2020 10:34:41 +0000 (11:34 +0100)]
container: force rm --storage on ExecStartPre

This is a workaround to avoid error like following:
```
Error: error creating container storage: the container name "ceph-mgr-magna022" is already in use by "4a5f674e113f837a0cc561dea5d2cd55d16ca159a647b7794ab06c4c276ef701"
```

that doesn't seem to be 100% reproducible but it shows up after a
reboot. The only workaround we came up with at the moment is to run
`podman rm --storage <container>` before starting it.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1887716
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-facts: Fix osd_pool_default_crush_rule fact
Benoît Knecht [Wed, 7 Oct 2020 07:44:29 +0000 (09:44 +0200)]
ceph-facts: Fix osd_pool_default_crush_rule fact

The `osd_pool_default_crush_rule` is set based on `crush_rule_variable`, which
is the output of a `grep` command.

However, two consecutive tasks can set that variable, and if the second task is
skipped, it still overwrites the `crush_rule_variable`, leading the
`osd_pool_default_crush_rule` to be set to `ceph_osd_pool_default_crush_rule`
instead of the output of the first task.

This commit ensures that the fact is set right after the `crush_rule_variable`
is assigned, before it can be overwritten.

Closes #5912

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
4 years agoconfig: Always use osd_memory_target if set
Gaudenz Steinlin [Mon, 28 Oct 2019 09:41:26 +0000 (10:41 +0100)]
config: Always use osd_memory_target if set

The osd_memory_target variable was only used if it was higher than the
calculated value based on the number of OSDs. This is changed to always
use the value if it is set in the configuration. This allows this value
to be intentionally set lower so that it does not have to be changed
when more OSDs are added later.

Signed-off-by: Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
4 years agomain: followup on pr 6012
Guillaume Abrioux [Thu, 12 Nov 2020 14:19:42 +0000 (15:19 +0100)]
main: followup on pr 6012

This tag can be set at the play level.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoswitch2container: disable ceph-osd enabled-runtime
Dimitri Savineau [Mon, 19 Oct 2020 21:22:31 +0000 (17:22 -0400)]
switch2container: disable ceph-osd enabled-runtime

When deploying the ceph OSD via the packages then the ceph-osd@.service
unit is configured as enabled-runtime.
This means that each ceph-osd service will inherit from that state.
The enabled-runtime systemd state doesn't survive after a reboot.
For non containerized deployment the OSD are still starting after a
reboot because there's the ceph-volume@.service and/or ceph-osd.target
units that are doing the job.

$ systemctl list-unit-files|egrep '^ceph-(volume|osd)'|column -t
ceph-osd@.service     enabled-runtime
ceph-volume@.service  enabled
ceph-osd.target       enabled

When switching to containerized deployment we are stopping/disabling
ceph-osd@XX.servive, ceph-volume and ceph.target and then removing the
systemd unit files.
But the new systemd units for containerized ceph-osd service will still
inherit from ceph-osd@.service unit file.

As a consequence, if an OSD host is rebooting after the playbook execution
then the ceph-osd service won't come back because they aren't enabled at
boot.

This patch also adds a reboot and testinfra run after running the switch
to container playbook.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1881288
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoAdd ceph_client tag to execute or skip the playbook
Francesco Pantano [Mon, 9 Nov 2020 16:25:17 +0000 (17:25 +0100)]
Add ceph_client tag to execute or skip the playbook

There are some use cases where there's a need to skip the execution
of the ceph-ansible client role even though the client section of the
inventory isn't empty.
This can happen in contexts where the services are colocated or when
a all-in-one deployment is performed.
The purpose of this change is adding a 'ceph_client' tag to avoid
altering the ceph-ansible execution flow but at the same time be able
to include or exclude a set of tasks using this tag.

Signed-off-by: Francesco Pantano <fpantano@redhat.com>
4 years agorolling_update: always run cv simple scan/activate
Dimitri Savineau [Mon, 9 Nov 2020 22:02:17 +0000 (17:02 -0500)]
rolling_update: always run cv simple scan/activate

There's no need to use a condition on the ceph release for the
ceph-volume simple commands.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agodashboard: change dashboard_grafana_api_no_ssl_verify default value
Guillaume Abrioux [Tue, 3 Nov 2020 15:32:17 +0000 (16:32 +0100)]
dashboard: change dashboard_grafana_api_no_ssl_verify default value

This sets the `dashboard_grafana_api_no_ssl_verify` default value
according to the length of `dashboard_crt` and `dashboard_key`.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agodashboard: enable https by default
Guillaume Abrioux [Tue, 3 Nov 2020 12:49:59 +0000 (13:49 +0100)]
dashboard: enable https by default

see linked bz for details

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1889426
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoosd: Fix number of OSD calculation
Gaudenz Steinlin [Tue, 27 Aug 2019 13:15:35 +0000 (15:15 +0200)]
osd: Fix number of OSD calculation

If some OSDs are to be created and others already exist the calculation
only counted the to be created OSDs. This changes the calculation to
take all OSDs into account.

Signed-off-by: Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
4 years agorolling_update: fix mgr start with mon collocation
Dimitri Savineau [Fri, 30 Oct 2020 14:54:16 +0000 (10:54 -0400)]
rolling_update: fix mgr start with mon collocation

cec994b introduced a regression when a mgr is collocated with a mon.
During the mon upgrade, the mgr service is masked to avoid to be
restarted on packages update.
Then the start mgr task is failing because the service is still masked.
Instead we should unmask it.

Fixes: #5983
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoinfrastructure: consume ceph_fs module
Dimitri Savineau [Fri, 23 Oct 2020 15:46:30 +0000 (11:46 -0400)]
infrastructure: consume ceph_fs module

bd611a7 introduced the new ceph_fs module but missed some tasks in
rolling_update and shrink-mds playbooks.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agorolling_update: use ceph health instead of ceph -s
Dimitri Savineau [Mon, 26 Oct 2020 23:35:06 +0000 (19:35 -0400)]
rolling_update: use ceph health instead of ceph -s

The ceph status command returns a lot of information stored in variables
and/or facts which could consume resources for nothing.
When checking the cluster health, we're using the health structure in the
ceph status output.
To optimize this, we could use the ceph health command which contains
the same needed information.

$ ceph status -f json | wc -c
2001
$ ceph health -f json | wc -c
46

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agorgw/rbdmirror: use service dump instead of ceph -s
Dimitri Savineau [Mon, 26 Oct 2020 21:49:47 +0000 (17:49 -0400)]
rgw/rbdmirror: use service dump instead of ceph -s

The ceph status command returns a lot of information stored in variables
and/or facts which could consume resources for nothing.
When checking the rgw/rbdmirror services status, we're only using the
servicmap structure in the ceph status output.
To optimize this, we could use the ceph service dump command which contains
the same needed information.
This command returns less information and is slightly faster than the ceph
status command.

$ ceph status -f json | wc -c
2001
$ ceph service dump -f json | wc -c
1105
$ time ceph status -f json > /dev/null

real 0m0.557s
user 0m0.516s
sys 0m0.040s
$ time ceph service dump -f json > /dev/null

real 0m0.454s
user 0m0.434s
sys 0m0.020s

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agomonitor: use quorum_status instead of ceph status
Dimitri Savineau [Mon, 26 Oct 2020 21:33:45 +0000 (17:33 -0400)]
monitor: use quorum_status instead of ceph status

The ceph status command returns a lot of information stored in variables
and/or facts which could consume resources for nothing.
When checking the quorum status, we're only using the quorum_names
structure in the ceph status output.
To optimize this, we could use the ceph quorum_status command which contains
the same needed information.
This command returns less information.

$ ceph status -f json  | wc -c
2001
$ ceph quorum_status -f json  | wc -c
957
$ time ceph status -f json > /dev/null

real 0m0.577s
user 0m0.538s
sys 0m0.029s
$ time ceph quorum_status -f json > /dev/null

real 0m0.544s
user 0m0.527s
sys 0m0.016s

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoosds: use pg stat command instead of ceph status
Dimitri Savineau [Mon, 26 Oct 2020 15:23:01 +0000 (11:23 -0400)]
osds: use pg stat command instead of ceph status

The ceph status command returns a lot of information stored in variables
and/or facts which could consume resources for nothing.
When checking the pgs state, we're using the pgmap structure in the ceph
status output.
To optimize this, we could use the ceph pg stat command which contains
the same needed information.
This command returns less information (only about pgs) and is slightly
faster than the ceph status command.

$ ceph status -f json | wc -c
2000
$ ceph pg stat -f json | wc -c
240
$ time ceph status -f json > /dev/null

real 0m0.529s
user 0m0.503s
sys 0m0.024s
$ time ceph pg stat -f json > /dev/null

real 0m0.426s
user 0m0.409s
sys 0m0.016s

The data returned by the ceph status is even bigger when using the
nautilus release.

$ ceph status -f json | wc -c
35005
$ ceph pg stat -f json | wc -c
240

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoosds: use ceph osd stat instead of ceph status
wangxiaotong [Sat, 24 Oct 2020 13:59:17 +0000 (21:59 +0800)]
osds: use ceph osd stat instead of ceph status

Improve the checked way of the OSD created checking process.
This replaces the ceph status command by the ceph osd stat command.
The osdmap structure isn't needed anymore.

$ ceph status -f json | wc -c
2001
$ ceph osd stat -f json | wc -c
132
$ time ceph status -f json > /dev/null

real    0m0.563s
user    0m0.526s
sys     0m0.036s
$ time ceph osd stat -f json > /dev/null

real 0m0.457s
user 0m0.411s
sys 0m0.045s

Signed-off-by: wangxiaotong <wangxiaotong@fiberhome.com>
4 years agocommon: follow up on #5948
Guillaume Abrioux [Mon, 2 Nov 2020 14:56:28 +0000 (15:56 +0100)]
common: follow up on #5948

In addition to f7e2b2c608eef4bbba47586f1e24d6ade1572758

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-mon: Don't set monitor directory mode recursively
Benoît Knecht [Wed, 28 Oct 2020 15:09:58 +0000 (16:09 +0100)]
ceph-mon: Don't set monitor directory mode recursively

After rolling updates performed with
`infrastructure-playbooks/rolling_updates.yml`, files located in
`/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}` had mode 0755 (including
the keyring), making them world-readable.

This commit separates the task that configured permissions recursively on
`/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}` into two separate tasks:

1. Set the ownership and mode of the directory itself;
2. Recursively set ownership in the directory, but don't modify the mode.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
4 years agolibrary: remove unused module import
Dimitri Savineau [Tue, 27 Oct 2020 16:14:19 +0000 (12:14 -0400)]
library: remove unused module import

Move the import at the top of the file and remove unused module import.

- E402 module level import not at top of file
- F401 'xxxx' imported but unused

This also removes the '# noqa E402' statement from the code.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agokeyring: use ceph_key module for get-or-create cmd
Dimitri Savineau [Fri, 23 Oct 2020 22:03:49 +0000 (18:03 -0400)]
keyring: use ceph_key module for get-or-create cmd

Instead of using ceph auth get-or-create command via the ansible command
module then we can use the ceph_key module.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agokeyring: use ceph_key module for auth get command
Dimitri Savineau [Fri, 23 Oct 2020 19:19:53 +0000 (15:19 -0400)]
keyring: use ceph_key module for auth get command

Instead of using ceph auth get command via the ansible command module
then we can use the ceph_key module and the info state.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary/ceph_key: add output format parameter
Dimitri Savineau [Fri, 23 Oct 2020 18:50:52 +0000 (14:50 -0400)]
library/ceph_key: add output format parameter

The ceph_key module currently only supports the json output for the
info state.
When using this state on an entity then we something want the output
as:
  - plain for copying it to another node.
  - json in order to get only a subset information of the entity (like
the key or caps).

This patch adds the output_format parameter which uses json as a
default value for backward compatibility. It removes the internal and
hardcoded variable also called output_format.
In addition of json and plain outputs, there's also xml and yaml
values available.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoopenstack: use ceph_keyring_permissions by default
Gaudenz Steinlin [Mon, 10 Aug 2020 09:52:56 +0000 (11:52 +0200)]
openstack: use ceph_keyring_permissions by default

Otherwise this task fails if no permission is set on the item.
Previously the code omited the mode parameter if it was not set, but
this was lost with commit ab370b6ad823e551cfc324fd9c264633a34b72b5.

Signed-off-by: Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
4 years agopodman: force log driver to journald
Dimitri Savineau [Thu, 22 Oct 2020 14:59:15 +0000 (10:59 -0400)]
podman: force log driver to journald

Since we've changed to podman configuration using the detach mode and
systemd type to forking then the container logs aren't present in the
journald anymore.
The default conmon log driver is using k8s-file.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1890439
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoceph-handler: fix curl ipv6 command with rgw
Dimitri Savineau [Thu, 22 Oct 2020 19:05:12 +0000 (15:05 -0400)]
ceph-handler: fix curl ipv6 command with rgw

When using the curl command with ipv6 address and brackets then we need
to use the -g option otherwise the command fails.

$ curl http://[fdc2:328:750b:6983::6]:8080
curl: (3) [globbing] error: bad range specification after pos 9

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoiscsi: fix ownership on iscsi-gateway.cfg
Guillaume Abrioux [Wed, 21 Oct 2020 12:26:57 +0000 (14:26 +0200)]
iscsi: fix ownership on iscsi-gateway.cfg

This file is currently deployed with '0644' ownership making this file
readable by any user on the system.
Since it contains sensitive information it should be readable by the
owner only.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1890119
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agocommon: drop `fetch_directory` feature
Guillaume Abrioux [Tue, 6 Oct 2020 05:53:06 +0000 (07:53 +0200)]
common: drop `fetch_directory` feature

This commit drops the `fetch_directory` feature.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-config: ceph.conf rendering refactor
Guillaume Abrioux [Mon, 5 Oct 2020 15:41:20 +0000 (17:41 +0200)]
ceph-config: ceph.conf rendering refactor

This commit cleans up the `main.yml` task file of `ceph-config`.
It drops the local ceph.conf generation.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agocrash: refact caps definition
Guillaume Abrioux [Mon, 19 Oct 2020 14:57:53 +0000 (16:57 +0200)]
crash: refact caps definition

there is no need to use `{{ }}` syntax here.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-volume: refresh lvm metadata cache
Guillaume Abrioux [Mon, 19 Oct 2020 08:22:21 +0000 (10:22 +0200)]
ceph-volume: refresh lvm metadata cache

When running rhel8 containers on a rhel7 host, after zapping an OSD
there's a discrepancy with the lvmetad cache that needs to be refreshed.
Otherwise, the host still sees the lv and can makes the user confused.
If user tries to redeploy an OSD, it will fail because the LV isn't
present and need to be recreated.

ie:

```
 stderr: lsblk: ceph-block-8/block-8: not a block device
 stderr: blkid: error: ceph-block-8/block-8: No such file or directory
 stderr: Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.
usage: ceph-volume lvm prepare [-h] --data DATA [--data-size DATA_SIZE]
                               [--data-slots DATA_SLOTS] [--filestore]
                               [--journal JOURNAL]
                               [--journal-size JOURNAL_SIZE] [--bluestore]
                               [--block.db BLOCK_DB]
                               [--block.db-size BLOCK_DB_SIZE]
                               [--block.db-slots BLOCK_DB_SLOTS]
                               [--block.wal BLOCK_WAL]
                               [--block.wal-size BLOCK_WAL_SIZE]
                               [--block.wal-slots BLOCK_WAL_SLOTS]
                               [--osd-id OSD_ID] [--osd-fsid OSD_FSID]
                               [--cluster-fsid CLUSTER_FSID]
                               [--crush-device-class CRUSH_DEVICE_CLASS]
                               [--dmcrypt] [--no-systemd]
ceph-volume lvm prepare: error: Unable to proceed with non-existing device: ceph-block-8/block-8
```

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1886534
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph-osd: Fix check mode for start osds tasks
Benoît Knecht [Mon, 19 Oct 2020 09:39:06 +0000 (11:39 +0200)]
ceph-osd: Fix check mode for start osds tasks

Correctly set `osd_ids_non_container.stdout_lines` to an empty list if it's
undefined (i.e. in check mode).

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
4 years agoceph-mon: Fix check mode for deploy monitor tasks
Benoît Knecht [Mon, 19 Oct 2020 09:23:59 +0000 (11:23 +0200)]
ceph-mon: Fix check mode for deploy monitor tasks

Skip the `get initial keyring when it already exists` task when both commands
whose `stdout` output it requires have been skipped (e.g. when running in check
mode).

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
4 years agoceph-crash: Only deploy key to targeted hosts
Gaudenz Steinlin [Mon, 10 Aug 2020 09:38:47 +0000 (11:38 +0200)]
ceph-crash: Only deploy key to targeted hosts

The current task installs the ceph-crash key to "most" hosts via
"delegate_to". This key is only used by the ceph-crash daemon and should
just be installed on all hosts targeted by this role. There is no need
for using a delegated task.

Signed-off-by: Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch>
4 years agoceph-osd: start osd after systemd overrides
Guillaume Abrioux [Wed, 14 Oct 2020 06:52:02 +0000 (08:52 +0200)]
ceph-osd: start osd after systemd overrides

The service should be started after the ceph-osd systemd overrides has
been added, otherwise, the latter isn't considered.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1860739
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agocontainer: remove container_binding_name variable
Dimitri Savineau [Fri, 9 Oct 2020 18:34:14 +0000 (14:34 -0400)]
container: remove container_binding_name variable

The container_binding_name package was only mandatory when we were
using the docker modules (docker_image and docker_container) but since
we manage both docker and podman containers without using the dedicated
module then we can remove it.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoceph-osd: don't start the OSD services twice
Dimitri Savineau [Wed, 14 Oct 2020 00:43:53 +0000 (20:43 -0400)]
ceph-osd: don't start the OSD services twice

Using the + operation on two lists doesn't filter out the duplicate
keys.
Currently each OSDs is started (via systemd) twice.
Instead we could use the union filter.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agohandler: refact check_socket_non_container
Guillaume Abrioux [Tue, 6 Oct 2020 12:58:46 +0000 (14:58 +0200)]
handler: refact check_socket_non_container

the `stat --printf=%n` returns something like following:

```
ok: [osd0] => changed=false
  cmd: |-
    stat --printf=%n /var/run/ceph/ceph-osd*.asok
  delta: '0:00:00.009388'
  end: '2020-10-06 06:18:28.109500'
  failed_when_result: false
  rc: 0
  start: '2020-10-06 06:18:28.100112'
  stderr: ''
  stderr_lines: <omitted>
  stdout: /var/run/ceph/ceph-osd.2.asok/var/run/ceph/ceph-osd.5.asok
  stdout_lines: <omitted>
```

it makes the next task "check if the ceph osd socket is in-use" grep
like this:

```
ok: [osd0] => changed=false
  cmd:
  - grep
  - -q
  - /var/run/ceph/ceph-osd.2.asok/var/run/ceph/ceph-osd.5.asok
  - /proc/net/unix
```

which will obviously fail because this path never exists. It makes the
OSD handler broken.

Let's use `find` module instead.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoFix Ansible check mode for site.yml.sample playbook
Benoît Knecht [Tue, 1 Sep 2020 09:24:59 +0000 (11:24 +0200)]
Fix Ansible check mode for site.yml.sample playbook

Make sure the `site.yml.sample` playbook can be run in check mode by skipping
tasks that try to read the output of commands that have been skipped.

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
4 years agotests: change cephfs pool size
Guillaume Abrioux [Tue, 6 Oct 2020 08:55:37 +0000 (10:55 +0200)]
tests: change cephfs pool size

`all_daemons` scenario can't handle pools with `size: 3` because we have
1 osd node in root=HDD and two nodes in root=default.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: add radosgw_zone module
Dimitri Savineau [Wed, 26 Aug 2020 22:53:04 +0000 (18:53 -0400)]
library: add radosgw_zone module

This adds radosgw_zone ansible module for replacing the command module
usage with the radosgw-admin zone command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add radosgw_zonegroup module
Dimitri Savineau [Wed, 12 Aug 2020 21:43:29 +0000 (17:43 -0400)]
library: add radosgw_zonegroup module

This adds radosgw_zonegroup ansible module for replacing the command
module usage with the radosgw-admin zonegroup command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add radosgw_realm module
Dimitri Savineau [Thu, 6 Aug 2020 13:48:58 +0000 (09:48 -0400)]
library: add radosgw_realm module

This adds radosgw_realm ansible module for replacing the command module
usage with the radosgw-admin realm command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agolibrary: add radosgw_user module
Dimitri Savineau [Fri, 22 May 2020 19:47:45 +0000 (15:47 -0400)]
library: add radosgw_user module

This adds radosgw_user ansible module for replacing the command module
usage with the radosgw-admin user command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoinfrastructure-playbooks: drop add-osd playbook
Guillaume Abrioux [Tue, 15 Sep 2020 12:11:59 +0000 (14:11 +0200)]
infrastructure-playbooks: drop add-osd playbook

This playbook isn't needed anymore, we can achieve this operation by
running main playbook with `--limit` option.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agolibrary: add ceph_fs module
Dimitri Savineau [Wed, 30 Sep 2020 15:57:20 +0000 (11:57 -0400)]
library: add ceph_fs module

This adds the ceph_fs ansible module for replacing the command module
usage with the ceph fs command.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoflake8: run the workflow conditionally
Dimitri Savineau [Fri, 2 Oct 2020 16:14:36 +0000 (12:14 -0400)]
flake8: run the workflow conditionally

We don't need to run flake8 on ansible modules and their tests if we
don't have any modifitions.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoflake8: fix pep8 syntax on tests/functional/tests/
Guillaume Abrioux [Sun, 4 Oct 2020 08:32:45 +0000 (10:32 +0200)]
flake8: fix pep8 syntax on tests/functional/tests/

tests/conftest.py and tests present in tests/functional/tests/ has been
missed from previous commit

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agoceph_key: remove backward compatibility
Dimitri Savineau [Mon, 5 Oct 2020 15:16:44 +0000 (11:16 -0400)]
ceph_key: remove backward compatibility

It's time to remove this backward compatibility. Users had enough time
to convert their openstack_keys and key values.
We now fail in ceph-validate if the caps key isn't set.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
4 years agoceph_key: support using different keyring
Guillaume Abrioux [Sat, 3 Oct 2020 04:56:06 +0000 (06:56 +0200)]
ceph_key: support using different keyring

Currently the `ceph_key` module doesn't support using a different
keyring than `client.admin`.
This commit adds the possibility to use a different keyring.

Usage:
```
      ceph_key:
        name: "client.rgw.myrgw-node.rgw123"
        cluster: "ceph"
        user: "client.bootstrap-rgw"
        user_key: /var/lib/ceph/bootstrap-rgw/ceph.keyring
        dest: "/var/lib/ceph/radosgw/ceph-rgw.myrgw-node.rgw123/keyring"
        caps:
          osd: 'allow rwx'
          mon: 'allow rw'
          import_key: False
        owner: "ceph"
        group: "ceph"
        mode: "0400"
```

Where:
`user` corresponds to `-n (--name)`
`user_key` corresponds to `-k (--keyring)`

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
4 years agorgw: fix multi instances scaleout in baremetal
Guillaume Abrioux [Wed, 23 Sep 2020 15:47:20 +0000 (17:47 +0200)]
rgw: fix multi instances scaleout in baremetal

When rgw and osd are collocated, the current workflow prevents from
scaling out the radosgw_num_instances parameter when rerunning the
playbook in baremetal deployments.

When ceph-osd notifies handlers, it means rgw handlers are triggered
too. The issue with this is that they are triggered before the role
ceph-rgw is run.
In the case a scaleout operation is expected on `radosgw_num_instances`
it causes an issue because keyrings haven't been created yet so the new
instances won't start.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1881313
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>