almaops.ct_redis

Ansible Role: Redis Container

This role sets up a Redis container on the target host.

Requirements

The target host needs to have Docker running and the Docker PIP module installed.

Role Variables

For a complete list of available variables, check defaults/main.yml.

Network Settings

Variable Default Description
ct_redis_enable_ports true This flag controls if the default Redis port is allowed.
ct_redis_bind_addr "127.0.0.1" The IP address the Redis container will use.
ct_redis_bind_port "6379" The port the Redis container will use.
ct_redis_bind_ct_port "6379" The port the Redis server will use.
ct_redis_ct_ports_default [] The default ports for the Redis container. If {{ ct_redis_enable_ports }} is false, this list will be empty. If true, it will set to ["{{ ct_redis_bind_addr }}:{{ ct_redis_bind_port }}:{{ ct_redis_bind_ct_port }}"].
ct_redis_ct_ports_extra [] Additional user-defined ports for the container.
ct_redis_ct_ports {{ ct_redis_ct_ports_default + ct_redis_ct_ports_extra }} The complete list of ports for the container. This is passed to the ports parameter in the docker_container module.

Volume Settings

Variable Default Description
ct_redis_path_config_base /etc/ct_redis The directory for custom configuration files.
ct_redis_path_config_file {{ ct_redis_path_config_base }}/{{ ct_redis_ct_name }}.conf The configuration file name. Defaults to the container's name.
ct_redis_path_ct_config_file /usr/local/etc/redis/redis.conf The path to the custom config inside the container.
ct_redis_path_data_base /srv/ct_redis The base directory for data volumes.
ct_redis_path_data_volume {{ ct_redis_path_data_base }}/{{ ct_redis_ct_name }} The data directory mounted to the container.
ct_redis_path_ct_data /data The data directory inside the container.
ct_redis_ct_volumes_data ["{{ ct_redis_path_data_volume }}:{{ ct_redis_path_ct_data }}"] The data directory mount.
ct_redis_ct_volumes_config [] Custom config mount. If {{ ct_redis_enable_custom_config }} is true, it will be set to ["{{ ct_redis_path_config_file }}:{{ ct_redis_path_ct_config_file }}:ro"].
ct_redis_ct_volumes_extra [] Additional user-defined mounts for the container in the format ["/source:/dest"].
ct_redis_ct_volumes {{ ct_redis_ct_volumes_data + ct_redis_ct_volumes_config + ct_redis_ct_volumes_extra }} The complete set of mounts, passed to the volumes parameter in the docker_container module.

Custom Config

This role allows you to use a custom configuration file for the Redis container.

Variable Default Description
ct_redis_enable_custom_config false This flag controls if a custom config file is mounted to the container. If set to true, the variables {{ ct_redis_ct_volumes_config }} and {{ ct_redis_ct_command_custom_config }} will be taken from vars. Once enabled, a Redis config file will be created from a template on the target host and mounted to the container. The config file path will be added to the container's CMD.
ct_redis_cfg_extra {} Additional key-value pairs of Redis configuration parameters for the default custom config template.

Command

Variable Default Description
ct_redis_ct_command_custom_config [] The path to the custom config file inside the container, which is added to the container's CMD. If {{ ct_redis_enable_custom_config }} is true, it will be set to ["{{ ct_redis_path_ct_config_file }}"].
ct_redis_ct_command_options [] Additional user-defined options for the redis-server command.
ct_redis_ct_command {{ [\"redis-server\"] + ct_redis_ct_command_custom_config + ct_redis_ct_command_options }} The final command passed to the container as the command parameter of the docker_container module.

Dependencies

None.

Example Playbook

# Creates a Redis container bound to a custom IP address and port.
- hosts:
    - redis_server
  become: true
  roles:
    - role: almaops.ct_redis
      ct_redis_bind_addr: "192.168.0.10"
      ct_redis_bind_port: "26379"

# Creates a Redis container with a custom configuration from your own redis.conf template.
- hosts:
    - redis_server
  become: true
  roles:
    - role: almaops.ct_redis
      ct_redis_enable_custom_config: true
      ct_redis_template_config: "/path/to/custom/redis.conf.j2"

License

MIT

Contributors

Valentin Gostev.

Informazioni sul progetto

Ansible role deploys Redis container

Installa
ansible-galaxy install almaops.ct_redis
Licenza
mit
Download
489
Proprietario
Premium IT Consulting