Add better documentation and examples
Update READEME with detailed description of tasks files within role Create example playbooks Set better role defaults
This commit is contained in:
parent
a9cc0b3673
commit
da623d778b
77
README.md
77
README.md
|
@ -1,21 +1,44 @@
|
|||
OpenStack Operations
|
||||
=========
|
||||
# OpenStack Operations #
|
||||
|
||||
|
||||
Perform various common OpenStack operations by calling this role with an action and appropriate variables.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
## [WIP] Restart Services ##
|
||||
|
||||
None
|
||||
Restarting OpenStack service is complex. This role aims to intelligently evaluate the environment and determine how a service is running, what components constitute that service, and restart those components appropriately. This allows the operator to think in terms of the service that needs restarting rather than having to remember all the details required to restart that service.
|
||||
|
||||
## Fetch Logs ##
|
||||
|
||||
To fetch logs with this role, use the `fetch_logs.yml` tasks file. By default, every log file in `/var/log` matching the `*.log` pattern will be fetched from the remote and put into a folder adjacent to the playbook named for each host, preserving the directory structure as found on the remote host.
|
||||
|
||||
See `defaults/main.yml` for the dictionary of options to control logs that are fetched.
|
||||
|
||||
## Cleanup Docker ##
|
||||
|
||||
**WARNING:** This will delete images, containers, and volumes from the target system(s).
|
||||
|
||||
To perform the most common cleanup tasks -- delete dangling images and volumes and delete exited or dead containers -- use the `cleanup_docker.yml` tasks file. This role includes a `docker_facts` module for enumerating images, volumes, and containers. The filtered lists (one each for images, containers, and volumes) returned by this module is used to determine which items to remove. The module accepts a list of `k=v` filter arguments that will be passed to the `-f` option of Docker. Specifying multiple filters creates an `and` match, so all filters must match.
|
||||
|
||||
See Docker guides for [images](https://docs.docker.com/engine/reference/commandline/images/#filtering), [containers](https://docs.docker.com/engine/reference/commandline/ps/#filtering), and [volumes](https://docs.docker.com/engine/reference/commandline/volume_ls/#filtering) for filter options.
|
||||
|
||||
|
||||
## Requirements ##
|
||||
|
||||
- ansible >= 2.4
|
||||
- python >= 2.6
|
||||
- docker-py >= 1.7.0
|
||||
- Docker API >= 1.20
|
||||
|
||||
## Role Variables ##
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
**Variables used for cleaning up Docker**
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|-------------------|---------------------|----------------------|
|
||||
| `operations_docker_cleanup` | [see `defaults/main.yml`] | Filters used to determine which items will be removed. Uses Docker filter syntax. See Docker guides for [images](https://docs.docker.com/engine/reference/commandline/images/#filtering), [containers](https://docs.docker.com/engine/reference/commandline/ps/#filtering), and [volumes](https://docs.docker.com/engine/reference/commandline/volume_ls/#filtering) for filter options. |
|
||||
| `operations_image_filters` | `['dangling=true']` | List of image filters. |
|
||||
| `operations_volume_filters` | `['dangling=true']` | List of volume filters. |
|
||||
| `operations_container_filters` | `['status=exited', 'status=dead']` | List of container filters. |
|
||||
|
||||
**Variables for fetching logs**
|
||||
|
||||
|
@ -23,19 +46,22 @@ Role Variables
|
|||
|-------------------|---------------------|----------------------|
|
||||
| `operations_log_destination` | `{{ playbook_dir }}` | Path where logs will be stored when fetched from remote systems. |
|
||||
|
||||
|
||||
**Variables for restarting services**
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|-------------------|---------------------|----------------------|
|
||||
| `operations_service_names` | `[]` | List of services to restart on target systems. |
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
## Dependencies ##
|
||||
|
||||
None
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
## Example Playbooks ##
|
||||
|
||||
|
||||
### Restart Services ###
|
||||
|
||||
- hosts: all
|
||||
tasks:
|
||||
|
@ -44,17 +70,42 @@ Example Playbook
|
|||
name: openstack-operations
|
||||
tasks_from: restart_service.yml
|
||||
vars:
|
||||
operations_task: restart_service
|
||||
operations_service_names:
|
||||
- docker
|
||||
- keystone
|
||||
- mariadb
|
||||
|
||||
|
||||
### Cleanup Docker ###
|
||||
|
||||
- name: Cleanup dangling and dead images, containers, and volumes
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Cleanup unused Docker images, containers, and volumes
|
||||
import_role:
|
||||
name: openstack-operations
|
||||
tasks_from: cleanup_docker.yml
|
||||
|
||||
- name: Use custom filters for cleaning
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Cleanup unused Docker images, containers, and volumes
|
||||
import_role:
|
||||
name: openstack-operations
|
||||
tasks_from: cleanup_docker.yml
|
||||
vars:
|
||||
operations_image_filters:
|
||||
- before=image1
|
||||
operations_volume_filters:
|
||||
- label=my_volume
|
||||
operations_container_filters:
|
||||
- name=keystone
|
||||
|
||||
|
||||
|
||||
### Fetch Logs ###
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Fetch logs
|
||||
import_role:
|
||||
name: openstack-operations
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Cleanup Docker
|
||||
operations_docker_bin: docker
|
||||
operations_image_filters:
|
||||
- dangling=true
|
||||
operations_volume_filters:
|
||||
|
@ -11,6 +10,16 @@ operations_container_filters:
|
|||
|
||||
# Fetch Logs
|
||||
operations_log_destination: "{{ playbook_dir }}"
|
||||
operations_logs:
|
||||
# age:
|
||||
# contains:
|
||||
# file_type:
|
||||
# follow:
|
||||
paths: /var/log
|
||||
patterns: '*.log'
|
||||
recurse: yes
|
||||
# size:
|
||||
# use_regex:
|
||||
|
||||
|
||||
# Restart Service
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
- name: Cleanup Docker
|
||||
hosts: "{{ target_hosts | default('all') }}"
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Cleanup unused Docker images, containers, and volumes
|
||||
import_role:
|
||||
name: openstack-ops
|
||||
tasks_from: cleanup_docker.yml
|
|
@ -0,0 +1,9 @@
|
|||
- name: Fetch logs
|
||||
hosts: "{{ target_hosts | default('all') }}"
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Fetch logs from remote systems
|
||||
import_role:
|
||||
name: openstack-ops
|
||||
tasks_from: fetch_logs.yml
|
|
@ -0,0 +1,9 @@
|
|||
- name: Restart OpenStack services
|
||||
hosts: "{{ target_hosts | default('all') }}"
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Restart services
|
||||
import_role:
|
||||
name: openstack-ops
|
||||
tasks_from: restart_service.yml
|
Loading…
Reference in New Issue