Skip to content

AnsiblePlaybookConfigFormat

Pavel Zinin edited this page Sep 3, 2018 · 1 revision

VMEmperor Ansible Playbook Configuration

Prerequisites

In order to use an Ansible playbook, you must

  1. Configure ansible_dir parameter in the config file: set it to your location of Ansible playbooks (default: ``./ansible`)
  2. Configure ansible_logs parameter in the config file: set it to your desired location of Ansible playbooks execution logs (default: ./ansible_logs). You can view stdout output there
  3. Generate a SSH key for Ansible if not done before. If you use VMEmperor auto-installation, this key will be authorized in a VM
  4. Specify pubkey location in ansible_pubkey parameter in a config file
  5. (Optional) Set ansible_playbook parameter to the path to ansible-playbook binary if you use custom Ansible distribution

After that, put your Ansible playbooks in your ansible_dir location, one playbook per one subdirectory.

In each of Ansible playbook subdirectories you should create a file in YAML format named vmemperor.conf. An example is provided in VMEmperor distribution, directory ansible/wordpress-nginx

vmemperor.conf parameters

All parameters are not optional unless explicitly specified

name (string)

Human-readable playbook name

description (string)

Humnan-readable playbook description

playbook (string)

Path to playbook file (to run with ansible-playbook) relatively to current directory

inventory (string; optional)

Path to inventory file. If this option is specified, the playbook is only seen to administrators and operates on hosts specified in this inventory file. If not specified, the playbook is available for everyone and operates on hosts selected by user in user interface (i.e. hosts file is generated automatically)

requires (dictionary, optional)

Not stable - not defined yet

variables (dictionary, optional)

Specification of variables that are supposed to be overrided by user

Keys

Variable names taken from host_vars/all and group_vars/all

Value structure

Each value is a dictionary with the following keys:

  • description - human-readable variable description
  • type - variable type (see below)

Variable types

  • str - string
  • int - number
  • bool - check box
  • option - list of choices

type option

For type option there is one more dictionary key expected: options. Its value is a dictionary with all possible options as keys and dictionaries as values

options keys' values

Each value in options dictionary is a dictionary with a key named description and value providing human readable description for its option

vmemperor.conf Example

---
name: WordPress
description: WordPress CentOS Setup
playbook: site.yml
inventory: hosts
requires:
  os_version:
    - distro: centos
      major: 6
    - distro: redhat
variables:
  wp_version:
      description: WordPress version
      type: str
  wp_sha256sum:
      description: WordPress release SHA256
      type: str
  mysql_port:
      description: MySQL port
      type: int
  server_hostname:
      description: WordPress server hostname
      type: str
  auto_up_disable:
      description: Disable automatic updates
      type: bool
  core_update_level:
      description: Core Update Level
      type: option
      options:
        true:
                description: Development, minor, and major updates are all enabled
        false:
                description: Development, minor, and major updates are all disabled
        minor:
                description: Minor updates are enabled, development, and major updates are disabled