diff --git a/CHANGELOG.md b/CHANGELOG.md index 67539149..180d25d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -768,10 +768,14 @@ Actually add new template files :facepalm: - Consul v1.0.2 - Update documentation -## v1.30.1 (UNRELEASED) +## v1.30.1 - Add performance tuning configuration (thanks @t0k4rt) - Set raft multiplier to 1 -- Update documentation - Conditionally install Python dependency baed on virtualenv or --user Addresses https://github.com/brianshumate/ansible-consul/issues/129#issuecomment-356095611 +- Update includes to import_tasks and include_tasks +- Remove invalid consul_version key from configuration +- Update Vagrantfile + - Set client address to 0.0.0.0 so Vagrant based deploy checks now pass +- Update documentation diff --git a/README.md b/README.md index 5447e801..17316529 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ definitely known to work with the following specific software versions: * Consul: 1.0.2 * Ansible: 2.4.2.0 * CentOS: 7 -* Debian: 8 +* Debian: 9 * FreeBSD: 11 * RHEL: 7 * Ubuntu: 16.04 @@ -667,6 +667,27 @@ packages with different package names. - List of OS packages to install - Default value: list +### `consul_performance` + +- List of Consul performance tuning items +- Default value: list + +#### `raft_multiplier` + +- [Raft multiplier](https://www.consul.io/docs/agent/options.html#raft_multiplier) scales key Raft timing parameters +- Default value: 1 + +#### `leave_drain_time` + +- [Node leave drain time](https://www.consul.io/docs/agent/options.html#leave_drain_time) is the dwell time for a server to honor requests while gracefully leaving + +- Default value: 5s + +#### `rpc_hold_timeout` + +- [RPC hold timeout](https://www.consul.io/docs/agent/options.html#rpc_hold_timeout) is the duration that a client or server will retry internal RPC requests during leader elections +- Default value: 7s + ## Dependencies Ansible requires GNU tar and this role performs some local use of the @@ -813,21 +834,6 @@ consul3.node.consul. 0 IN A 10.1.42.230 - Custom list of addresses to listen on. - Default value: *[]* -### `consul_performance` - -This is a nested object of Consul performance related options. - -#### `consul_performance.raft_multiplier` - -This is the [raft multiplier](https://www.consul.io/docs/agent/options.html#raft_multiplier). See also [Server Performance](https://www.consul.io/docs/guides/performance.html). - -#### `consul_performance.leave_drain_time` - -This is the [leave drain time](https://www.consul.io/docs/agent/options.html#leave_drain_time). - -#### `consul_performance.rpc_hold_timeout` - -This is the [RPC hold timeout](https://www.consul.io/docs/agent/options.html#rpc_hold_timeout). ### iptables DNS Forwarding Support diff --git a/defaults/main.yml b/defaults/main.yml index 6ee372a9..9e0516d0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -181,7 +181,7 @@ consul_dnsmasq_local_service: false consul_dnsmasq_listen_addresses: [] consul_iptables_enable: "{{ lookup('env','CONSUL_IPTABLES_ENABLE') | default(false, true) }}" -# Consul performace +# Performance consul_performance: raft_multiplier: 1 leave_drain_time: 5s diff --git a/examples/README_VAGRANT.md b/examples/README_VAGRANT.md index 008c2d36..bf3a3717 100644 --- a/examples/README_VAGRANT.md +++ b/examples/README_VAGRANT.md @@ -1,22 +1,14 @@ # Consul with Ansible -This project provides documentation and a collection of scripts to help you -automate the deployment of Consul using -[Ansible](https://www.ansible.com/). These are the instructions for -deploying a development cluster on Vagrant and VirtualBox. +This project provides documentation and a collection of scripts to help you automate the deployment of Consul using [Ansible](https://www.ansible.com/). These are the instructions for deploying a development cluster on Vagrant and VirtualBox. -The documentation and scripts are merely a starting point designed to both -help familiarize you with the processes and quickly bootstrap an environment -for development. You may wish to expand on them and customize -them with additional features specific to your needs later. +The documentation and scripts are merely a starting point designed to both help familiarize you with the processes and quickly bootstrap an environment for development. You may wish to expand on them and customize them with additional features specific to your needs later. If you are looking for the main role documentation, it is in the [README.md](https://github.com/brianshumate/ansible-consul/blob/master/README.md). ## Vagrant Development Cluster -In some situations deploying a small cluster on your local development -machine can be handy. This document describes such a scenario using the -following technologies: +In some situations deploying a small cluster on your local development machine can be handy. This document describes such a scenario using the following technologies: * [Consul](https://consul.io) * [VirtualBox](https://www.virtualbox.org/) @@ -24,22 +16,15 @@ following technologies: supporting plugin * [Ansible](https://www.ansible.com/) -Each of the virtual machines for this guide are configured with -1GB RAM, 2 CPU cores, and 2 network interfaces. The first interface uses -NAT and has connection via the host to the outside world. The second -interface is a private network and is used for Consul intra-cluster -communication in addition to access from the host machine. +Each of the virtual machines for this guide are configured with 1GB RAM, 2 CPU cores, and 2 network interfaces. The first interface uses NAT and has connection via the host to the outside world. The second interface is a private network and is used for Consul intra-cluster communication in addition to access from the host machine. -The Vagrant configuration file (`Vagrantfile`) is responsible for -configuring the virtual machines and a baseline OS installation. +The Vagrant configuration file (`Vagrantfile`) is responsible for configuring the virtual machines and a baseline OS installation. -The Ansible playbooks then further refine OS configuration, perform Consul -software download, installation, configuration, and the joining of server nodes into a ready to use cluster. +The Ansible playbooks then further refine OS configuration, perform Consul software download, installation, configuration, and the joining of server nodes into a ready to use cluster. ## Designed for Ansible Galaxy -This role is designed to be installed via the `ansible-galaxy` command -instead of being directly run from the git repository. +This role is designed to be installed via the `ansible-galaxy` command instead of being directly run from the git repository. You should install it like this: @@ -47,9 +32,7 @@ You should install it like this: ansible-galaxy install brianshumate.consul ``` -You'll want to make sure you have write access to `/etc/ansible/roles/` since -that is where the role will be installed by default, or define your own -Ansible role path by creating a `$HOME/.ansible.cfg` or even `./anisible.cfg` +You'll want to make sure you have write access to `/etc/ansible/roles/` since that is where the role will be installed by default, or define your own Ansible role path by creating a `$HOME/.ansible.cfg` or even `./anisible.cfg` file with these contents: ``` @@ -61,8 +44,7 @@ Change `PATH_TO_ROLES` to a directory that you have write access to. ## Quick Start -Begin from the top level directory of this project and use the following -steps to get up and running: +Begin from the top level directory of this project and use the following steps to get up and running: 1. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads), [Vagrant](http://downloads.vagrantup.com/), [vagrant-hosts](https://github.com/adrienthebo/vagrant-hosts), and [Ansible](http://docs.ansible.com/ansible/intro_installation.html). 2. Edit `/etc/hosts` or use the included `bin/preinstall` script to add @@ -113,8 +95,7 @@ BOX_NAME=freebsd/FreeBSD-11.0-STABLE CONSUL_IFACE=em1 vagrant up * VirtualBox version 5.1.30 * Vagrant version 2.0.1 * Vagrant Hosts plugin version 2.8.0 -2. This project uses Debian 8 (Jessie) by default, but you can choose another - OS distribution with the *BOX_NAME* environment variable +2. This project uses Debian 9 (Stretch) by default, but you can choose another OS distribution with the *BOX_NAME* environment variable 3. The `bin/preinstall` shell script performs the following actions for you: * Adds each node's host information to the host machine's `/etc/hosts` * Optionally installs the Vagrant hosts plugin diff --git a/examples/Vagrantfile b/examples/Vagrantfile index f38660eb..d7acae57 100644 --- a/examples/Vagrantfile +++ b/examples/Vagrantfile @@ -40,7 +40,7 @@ SCRIPT ANSIBLE_PLAYBOOK = ENV['ANSIBLE_PLAYBOOK'] || "site.yml" BOX_MEM = ENV['BOX_MEM'] || "1024" -BOX_NAME = ENV['BOX_NAME'] || "debian/jessie64" +BOX_NAME = ENV['BOX_NAME'] || "debian/stretch64" CLUSTER_HOSTS = ENV['CLUSTER_HOSTS'] || "vagrant_hosts" CONSUL_ACL_ENABLE = ENV['CONSUL_ACL_ENABLE'] || "false" CONSUL_ATLAS_ENABLE = ENV['CONSUL_ATLAS_ENABLE'] || "false" @@ -139,10 +139,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # extra Ansible variables can be defined here as well. Wheeee! # ansible.extra_vars = { - consul_log_level: "DEBUG" + consul_log_level: "DEBUG", + consul_client_address: "10.1.42.230" } ansible.playbook = ANSIBLE_PLAYBOOK ansible.limit = "all" + compatibility_mode = "2.0" end end end diff --git a/handlers/main.yml b/handlers/main.yml index c6840c9c..38c33c99 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,10 +2,10 @@ # File: main.yml - Handlers for Consul - name: restart consul - include: restart_consul.yml + import_tasks: restart_consul.yml - name: start consul - include: start_consul.yml + import_tasks: start_consul.yml - name: restart dnsmasq service: diff --git a/tasks/main.yml b/tasks/main.yml index 59ede4ba..1a79d3b9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,7 +17,7 @@ when: is_virtualenv is defined - name: Include checks/asserts - include: asserts.yml + import_tasks: asserts.yml - name: Include OS-specific variables include_vars: "{{ ansible_os_family }}.yml" @@ -55,10 +55,10 @@ tags: always - name: Include user and group settings - include: user_group.yml + import_tasks: user_group.yml - name: Include directory settings - include: dirs.yml + import_tasks: dirs.yml - name: Check for existing Consul binary stat: @@ -70,19 +70,19 @@ consul_install_binary: "{{ consul_install_upgrade or not consul_binary_installed.stat.exists }}" - name: Install OS packages and consul - locally - include: install.yml + include_tasks: install.yml when: - consul_install_binary | bool - not consul_install_remotely | bool - name: Install OS packages and consul - remotely - include: install_remote.yml + include_tasks: install_remote.yml when: - consul_install_binary | bool - consul_install_remotely | bool # XXX: Individual gossip tasks are deprecated and need to be removed - # - include: ../tasks/encrypt_gossip.yml + # - include_tasks: ../tasks/encrypt_gossip.yml - block: - block: - name: Check for gossip encryption key on previously boostrapped server @@ -159,14 +159,14 @@ - consul_encrypt_enable - name: Create Consul configuration - include: config.yml + import_tasks: config.yml - name: Create ACL configuration - include: acl.yml + include_tasks: acl.yml when: consul_acl_enable | bool - name: Create TLS configuration - include: tls.yml + include_tasks: tls.yml when: consul_tls_enable | bool - block: @@ -240,7 +240,6 @@ - smfmanifest | changed - ansible_os_family == "Solaris" - - name: Start Consul service: name: consul @@ -250,7 +249,7 @@ - name: Check Consul HTTP API (via TCP socket) wait_for: delay: 15 - port: "{{consul_ports.http|int}}" + port: "{{ consul_ports.http|int }}" host: "{{ consul_addresses.http }}" when: (consul_ports.http|int > -1) and (consul_addresses.http|ipaddr) @@ -265,10 +264,10 @@ dest: "{{ consul_bootstrap_state }}" state: touch - - include: ../tasks/dnsmasq.yml + - include_tasks: ../tasks/dnsmasq.yml when: consul_dnsmasq_enable | bool - - include: ../tasks/iptables.yml + - include_tasks: ../tasks/iptables.yml when: consul_iptables_enable | bool when: not bootstrap_state.stat.exists @@ -310,7 +309,7 @@ tags: always - name: (Windows) Include directory settings - include: dirs.yml + import_tasks: dirs.yml - name: (Windows) Check for existing Consul binary win_stat: @@ -318,7 +317,7 @@ register: consul_binary_installed - name: (Windows) Install OS packages and consul - include: install_windows.yml + include_tasks: install_windows.yml when: - not consul_binary_installed.stat.exists | bool @@ -397,7 +396,7 @@ - consul_encrypt_enable - name: (Windows) Create Consul configuration - include: config_windows.yml + import_tasks: config_windows.yml - name: (Windows) Ensure neither ACL nor TLS are requested fail: @@ -406,11 +405,11 @@ - (consul_acl_enable | bool) or (consul_tls_enable | bool) - name: (Windows) Create ACL configuration - include: acl.yml + include_tasks: acl.yml when: consul_acl_enable | bool - name: (Windows) Create TLS configuration - include: tls.yml + include_tasks: tls.yml when: consul_tls_enable | bool - block: @@ -436,17 +435,16 @@ host: "{{inventory_hostname_short}}" port: 8500 - - name: (Windows) Create bootstrapped state file win_file: dest: "{{consul_bootstrap_state}}" state: touch when: ansible_os_family == "Windows" - - include: ../tasks/dnsmasq.yml + - include_tasks: ../tasks/dnsmasq.yml when: consul_dnsmasq_enable | bool - - include: ../tasks/iptables.yml + - include_tasks: ../tasks/iptables.yml when: consul_iptables_enable | bool when: not bootstrap_state.stat.exists diff --git a/templates/config.json.j2 b/templates/config.json.j2 index e2922cae..7ed43d14 100644 --- a/templates/config.json.j2 +++ b/templates/config.json.j2 @@ -7,12 +7,9 @@ "node_name": "{{ consul_node_name }}", "datacenter": "{{ consul_datacenter }}", "domain": "{{ consul_domain }}", - "consul_version": "{{consul_version}}", - {% if consul_version | version_compare('0.7.3', '>=') and - consul_node_meta | length > 0 %} + {% if consul_version | version_compare('0.7.3', '>=') and consul_node_meta | length > 0 %} "node_meta": {{ consul_node_meta | default({})| to_json }}, {% endif %} - {# Performance Settings #} "performance": {{ consul_performance | to_json }}, @@ -28,7 +25,7 @@ "dns": "{{ consul_addresses.dns }}", "http": "{{ consul_addresses.http }}", "https": "{{ consul_addresses.https }}" - + }, {## Ports Used ##} "ports": { @@ -90,7 +87,7 @@ {## LAN Join ##} "retry_interval": "{{ consul_retry_interval }}", "retry_max": {{ consul_retry_max | int }}, - "retry_join": + "retry_join": {% for server in _consul_lan_servers %} {% set consul_join = consul_join + [ hostvars[server]['consul_advertise_address'] | default(hostvars[server]['consul_bind_address']) ] %}{% if loop.last %} {{ consul_join | map('ipwrap') | list | to_json }}, diff --git a/version.txt b/version.txt index c8c2eaea..46aa51be 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.30.0 +v1.30.1