Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #341 from mikedep333/7005_single_meta_role
Browse files Browse the repository at this point in the history
As a user, I can run a single stably-named Ansible role
  • Loading branch information
mikedep333 committed Jun 22, 2020
2 parents 38dd67c + dd70e48 commit 892bf10
Show file tree
Hide file tree
Showing 62 changed files with 211 additions and 123 deletions.
2 changes: 2 additions & 0 deletions CHANGES/7005.feature
@@ -0,0 +1,2 @@
Provide a single "pulp_all_services" role that users can specify instead of the current role list,
and refactor the underlying roles and their dependency tree.
3 changes: 2 additions & 1 deletion docs/index.md
Expand Up @@ -139,7 +139,8 @@ Roles

pulp_installer is equipped with the following roles:

- [pulp](roles/pulp/): installs Pulp 3 from PyPi or source and provides basic config.
- [pulp_common](roles/pulp_common): installs shared components of the Pulp 3 services from PyPi or source and provides basic config
- [pulp_api](roles/pulp_api): install, configure, and set the state of pulp API service
- [pulp_content](roles/pulp_content): install, configure, and set the state of pulp content app.
- [pulp_database](roles/pulp_database): optionally install a database, then configure for Pulp.
- [pulp_redis](roles/pulp_redis): install and start Redis, and install RQ in the Pulp virtualenv.
Expand Down
6 changes: 1 addition & 5 deletions docs/quickstart.md
Expand Up @@ -84,11 +84,7 @@ vim install.yml
# pulp-python: {}
pulp-rpm: {}
roles:
- pulp.pulp_installer.pulp_database
- pulp.pulp_installer.pulp_workers
- pulp.pulp_installer.pulp_resource_manager
- pulp.pulp_installer.pulp_webserver
- pulp.pulp_installer.pulp_content
- pulp.pulp_installer.pulp_all_services
environment:
DJANGO_SETTINGS_MODULE: pulpcore.app.settings
```
Expand Down
1 change: 0 additions & 1 deletion docs/roles/pulp.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/roles/pulp_api.md
1 change: 1 addition & 0 deletions docs/roles/pulp_common.md
3 changes: 2 additions & 1 deletion mkdocs.yml
Expand Up @@ -11,7 +11,8 @@ nav:
- Getting started: quickstart.md
- contributing.md
- Roles:
- Pulp: roles/pulp.md
- Pulp Common: roles/pulp_common.md
- Pulp API: roles/pulp_api.md
- Pulp Content: roles/pulp_content.md
- Pulp Database: roles/pulp_database.md
- Pulp Devel: roles/pulp_devel.md
Expand Down
9 changes: 5 additions & 4 deletions molecule/release-dynamic/converge.yml
Expand Up @@ -9,16 +9,17 @@
msg: >
"You must update Ansible to at least 2.8 to use this version of Pulp 3 Installer."
tasks:
- name: Dynamically include prereq roles
- name: Dynamically include individual roles
include_role:
name: "{{ roleinputvar }}"
loop:
- pulp_redis
- pulp_database
- pulp_workers
- pulp_redis
- pulp_api
- pulp_content
- pulp_resource_manager
- pulp_workers
- pulp_webserver
- pulp_content
loop_control:
loop_var: roleinputvar
environment:
Expand Down
7 changes: 4 additions & 3 deletions molecule/source-dynamic/converge.yml
Expand Up @@ -13,12 +13,13 @@
include_role:
name: "{{ roleinputvar }}"
loop:
- pulp_redis
- pulp_database
- pulp_workers
- pulp_redis
- pulp_api
- pulp_content
- pulp_resource_manager
- pulp_workers
- pulp_webserver
- pulp_content
- pulp_devel
loop_control:
loop_var: roleinputvar
Expand Down
7 changes: 1 addition & 6 deletions playbooks/example-source/playbook.yml
Expand Up @@ -9,12 +9,7 @@
msg: >
"You must update Ansible to at least 2.8 to use this version of Pulp 3 Installer."
roles:
- pulp_redis
- pulp_database
- pulp_workers
- pulp_resource_manager
- pulp_webserver
- pulp_content
- pulp_all_services
- pulp_devel
environment:
DJANGO_SETTINGS_MODULE: pulpcore.app.settings
7 changes: 1 addition & 6 deletions playbooks/example-use/playbook.yml
Expand Up @@ -9,11 +9,6 @@
msg: >
"You must update Ansible to at least 2.8 to use this version of Pulp 3 Installer."
roles:
- pulp_redis
- pulp_database
- pulp_workers
- pulp_resource_manager
- pulp_webserver
- pulp_content
- pulp_all_services
environment:
DJANGO_SETTINGS_MODULE: pulpcore.app.settings
20 changes: 20 additions & 0 deletions roles/pulp_all_services/README.md
@@ -0,0 +1,20 @@
pulp_all_services
=================

A role to install all Pulp services on a single host.

Users are supposed to specify this role as a single stable role name
in their playbooks, rather than every single service role name, which
are subject to change. The exception is when they want certain services
on certain hosts.

Currently, all it does is depend on the required roles, which are
subject to change over time:
- pulp_database
- pulp_redis
- pulp_api
- pulp_content
- pulp_resource_manager
- pulp_workers
- pulp_webserver
- pulp_common (implicitly)
2 changes: 2 additions & 0 deletions roles/pulp_all_services/defaults/main.yml
@@ -0,0 +1,2 @@
---
# defaults file for pulp_all_services
2 changes: 2 additions & 0 deletions roles/pulp_all_services/handlers/main.yml
@@ -0,0 +1,2 @@
---
# handlers file for pulp_all_services
31 changes: 31 additions & 0 deletions roles/pulp_all_services/meta/main.yml
@@ -0,0 +1,31 @@
---
galaxy_info:
author: Pulp Team
description: A role to install all Pulp services on a single host.
issue_tracker_url: https://pulp.plan.io/projects/pulp/issues/new
license: GPL-2.0-or-later
company: Red Hat
min_ansible_version: 2.8
platforms:
- name: Debian
versions:
- buster
- name: Fedora
versions:
- 30
- 31
- name: EL
versions:
- 7
- 8
galaxy_tags:
- pulp
- pulpcore
dependencies:
- pulp_database
- pulp_redis
- pulp_api
- pulp_content
- pulp_resource_manager
- pulp_workers
- pulp_webserver
5 changes: 5 additions & 0 deletions roles/pulp_all_services/tasks/main.yml
@@ -0,0 +1,5 @@
---
# tasks file for pulp_all_services

# This role simply uses dependencies at this time.
# meta/main.yml
2 changes: 2 additions & 0 deletions roles/pulp_all_services/vars/main.yml
@@ -0,0 +1,2 @@
---
# vars file for pulp_all_services
30 changes: 30 additions & 0 deletions roles/pulp_api/README.md
@@ -0,0 +1,30 @@
pulp_api
=========

Install, configure, and set the state of the pulp API service.

Role Variables
--------------

A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.

* `pulp_api_bind` Interface and Port where Pulp Content `gunicorn` service will listen. Defaults to
'127.0.0.1:24817'. This variable is the value used to render the `pulpcore-api.service.j2` template
passing to the `--bind` parameter of the `gunicorn` service.
* `pulp_api_workers`: Number of Pulp Content `gunicorn` processes for handling requests. Defaults to 1.
Used to render the `pulpcore-api.service.j2` template, passing to the `--workers` parameter of the
gunicorn service.

Shared variables
----------------

* `ansible_python_interpreter`: **Required**. Path to the Python interpreter.

This role **is tightly coupled** to the required `pulp_common` role, and inherits
some of its variables.

* `pulp_config_dir`
* `pulp_install_dir`
* `pulp_ld_library_path`: An optional LD_LIBRARY_PATH environment variable for the pulpcore-api systemd process
* `pulp_settings_file`
* `pulp_user`
8 changes: 8 additions & 0 deletions roles/pulp_api/defaults/main.yml
@@ -0,0 +1,8 @@
---
# defaults file for pulp_api
pulp_api_bind: '127.0.0.1:24817'
pulp_api_workers: 1
pulp_config_dir: "/etc/pulp"
pulp_install_dir: '/usr/local/lib/pulp'
pulp_settings_file: "{{ pulp_config_dir }}/settings.py"
pulp_user: pulp
9 changes: 9 additions & 0 deletions roles/pulp_api/handlers/main.yml
@@ -0,0 +1,9 @@
---
# handlers file for pulp_api
- name: Restart pulpcore-api.service
systemd:
name: pulpcore-api.service
enabled: true
state: restarted
daemon_reload: true
become: true
25 changes: 25 additions & 0 deletions roles/pulp_api/meta/main.yml
@@ -0,0 +1,25 @@
---
galaxy_info:
author: Pulp Team
description: A role to setup Pulp 3's API service
issue_tracker_url: https://pulp.plan.io/projects/pulp/issues/new
license: GPL-2.0-or-later
company: Red Hat
min_ansible_version: 2.8
platforms:
- name: Debian
versions:
- buster
- name: Fedora
versions:
- 30
- 31
- name: EL
versions:
- 7
- 8
galaxy_tags:
- pulp
- pulpcore
dependencies:
- pulp_common
9 changes: 9 additions & 0 deletions roles/pulp/tasks/wsgi.yml → roles/pulp_api/tasks/main.yml
@@ -1,4 +1,5 @@
---
# tasks file for pulp_api
- block:

- name: Install pulpcore-api service files
Expand All @@ -11,4 +12,12 @@
become: true
notify: Restart pulpcore-api.service

- name: Set the pulpcore-api service state
systemd:
name: pulpcore-api.service
state: started
enabled: true
daemon_reload: true
become: true

when: pulp_install_api_service |bool
2 changes: 2 additions & 0 deletions roles/pulp_api/vars/main.yml
@@ -0,0 +1,2 @@
---
# vars file for pulp_api
18 changes: 3 additions & 15 deletions roles/pulp/README.md → roles/pulp_common/README.md
@@ -1,7 +1,7 @@
Pulp
====
Pulp Common
===========

Ansible role that installs Pulp 3 from PyPi or source and provides basic config.
Ansible role that installs shared components of the Pulp 3 services from PyPi or source and provides basic config.

The default administrative user for the Pulp application is: 'admin'

Expand Down Expand Up @@ -46,17 +46,13 @@ Role Variables
pulp-four:
prereq_role: "pulp.pulp_four_role" # role to run immediately before the venv is created
```
* `pulp_install_api_service`: Whether to create systemd service files for
pulpcore-api. Defaults to "true".
* `pulp_cache_dir`: Location of Pulp cache. Defaults to "/var/lib/pulp/tmp".
* `pulp_config_dir`: Directory which will contain Pulp configuration files.
Defaults to "/etc/pulp".
* `pulp_default_admin_password`: Initial password for the Pulp admin. **Required**.
* `pulp_install_dir`: Location of a virtual environment for Pulp and its Python
dependencies. Defaults to "/usr/local/lib/pulp".
* `pulp_user_home`: equivalent to `MEDIA_ROOT` from `pulpcore` i.e. absolute path for pulp user home.
* `pulp_install_api_service`: Whether to create systemd service files for
pulpcore-api. Defaults to "true".
* `pulp_source_dir`: Optional. Absolute path to pulpcore source code. If
present, pulpcore will be installed from source in editable mode. Also accepts
a pip VCS URL, to (for example) install the master branch.
Expand All @@ -71,12 +67,6 @@ Role Variables
* `pulp_use_system_wide_pkgs` Use python system-wide packages. Defaults to "false".
* `pulp_remote_user_environ_name` Optional. Set the `REMOTE_USER_ENVIRON_NAME` setting for Pulp.
This variable will be set as the value of `CONTENT_HOST` as the base path to build content URLs.
* `pulp_api_bind` Interface and Port where Pulp Content `gunicorn` service will listen. Defaults to
'127.0.0.1:24817'. This variable is the value used to render the `pulpcore-api.service.j2` template
passing to the `--bind` parameter of the `gunicorn` service.
* `pulp_api_workers`: Number of Pulp Content `gunicorn` processes for handling requests. Defaults to 1.
Used to render the `pulpcore-api.servie.j2` template, passing to the `--workers` parameter of the
gunicorn service.
* `pulp_settings`: A nested dictionary that is used to add custom values to the user's
`setting.py`, which will override any default values set by pulpcore. The keys of this
dictionary are variable names, and the values should be expressed using the [Dynaconf syntax](
Expand Down Expand Up @@ -170,8 +160,6 @@ This role is required by the `pulp_database` role and uses some variables from i

* `pulp_settings_db_defaults`: See pulp_database README.

* `pulp_ld_library_path`: An optional LD_LIBRARY_PATH environment variable for the pulpcore-api systemd process

Operating System Variables
--------------------------

Expand Down
Expand Up @@ -31,8 +31,6 @@ pulp_group_id:
pulp_user_home: '/var/lib/pulp'
pulp_pip_editable: yes
pulp_use_system_wide_pkgs: false
pulp_api_bind: '127.0.0.1:24817'
pulp_api_workers: 1
prereq_pip_packages: []
pulp_rhel_codeready_repo:
- codeready-builder-for-rhel-8-x86_64-rpms
Expand Down
@@ -1,12 +1,4 @@
---
- name: Restart pulpcore-api.service
systemd:
name: pulpcore-api.service
enabled: true
state: restarted
daemon_reload: true
become: true

# Workaround https://github.com/ansible/ansible/issues/34505
# by not using include_tasks
- name: Restart all Pulp services
Expand All @@ -19,6 +11,14 @@
changed_when: "staticresult.stdout is not search('\n0 static files')"
become: true
become_user: '{{ pulp_user }}'
notify: Restart pulpcore-api.service
# Not needed currently because every task that calls "Collect static content"
# also calls "Restart all Pulp services".
#
# And pulpcore-api is installed later on in the role order.
#
# However, restarting pulpcore-api is necessary for collectstatic to
# work; whitenoise cannot see the files unless pulpcore-api is restarted.
#
# notify: Restart pulpcore-api.service
environment:
PULP_SETTINGS: "{{ pulp_settings_file }}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -26,7 +26,7 @@
# require it.
with_dict: '{{ pulp_install_plugins }}'
when:
- item.value.pkg_name is undefined
- item.value.pkg_name is undefined
notify:
- Collect static content
- Restart all Pulp services
Expand All @@ -37,7 +37,7 @@
state: present
with_dict: '{{ pulp_install_plugins }}'
when:
- item.value.pkg_name is defined
- item.value.pkg_name is defined
notify:
- Collect static content
- Restart all Pulp services
Expand Down
File renamed without changes.
Expand Up @@ -86,4 +86,3 @@
- pulp_django_admin_path is not defined

- import_tasks: configure.yml
- import_tasks: wsgi.yml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 892bf10

Please sign in to comment.