Articles tagged with rhce

Ansible: Troubleshoot

3 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible can be configured to log its output to log files through the log_path parameter in the default section of the ansible.cfg configuration file.

Debug Module

The debug module provides insight into what is happening in the play.

Example:

- name: Display free memory
  debug:
    msg: "Free memory for this …

Read more

Ansible: Administration Tasks

9 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Managing Packages

The yum Ansible module uses the Yum Package Manager on the managed hosts to handle the package operations.

The following example is equivalent to yum install httpd

- name: Install httpd
  yum:
    name: httpd
    state: present

Run the ansible-doc yum command for additional parameters and playbook examples.

The package_facts …

Read more

Ansible: Roles

5 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible roles provide a way for you to make it easier to reuse Ansible code generically. A well-written role will allow you to pass variables to the role from the playbook that adjust its behavior, setting all the site-specific hostnames, IP addresses, user names, secrets, or other locally-specific details you …

Read more

Ansible: Projects

6 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Selecting Hosts with Host Patterns

Host patterns are used to specify the hosts to target by a play. At its most basic the name of a managed host or a host group in the inventory is a host pattern.

Hosts can be defined using hostname or IP address and must …

Read more

Ansible: Templates

1 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible uses the Jinja2 templating system for template files.

Variables and logic expressions are placed between tags, or delimiters.

Jinja2 templates use {% EXPR %} for expressions or logic.

{{ EXPR }} are used for outputting the results of an expression or a variable.

A Jinja2 template is composed of multiple elements: data, variables …

Read more

Ansible: Files

2 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

The Files modules library includes modules allowing you to accomplish most tasks related to Linux file management, such as creating, copying, editing, and modifying permissions and other attributes of files.

Common files modules include blockinfile,copy,fetch,file,lineinfile, stat and synchronize.

Use the file module to touch a file …

Read more

Ansible: Failures

1 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible evaluates the return code of each task to determine whether the task succeeded or failed. There are a number of Ansible features that can be used to manage task errors.

Ignoring Task Failure

By default, if a task fails, the play is aborted. You can use the ignore_errors keyword …

Read more

Ansible: Handlers

1 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible modules are designed to be idempotent. This means that in a properly written playbook, the playbook and its tasks can be run multiple times without changing the managed host unless they need to make a change to get the managed host to the desired state.

Handlers are tasks that …

Read more

Ansible: Loops

3 | Written on Tue 11 February 2020. Posted in Nuggets | Richard Walker

Ansible supports iterating a task over a set of items using the loop keyword, which enabled you to write a task that iterates over a list.

Simple Loops

A simple loop iterates a task over a list of items.

Example:

- name: Ensure services are running
  service:
    name: "{{ item }}"
    state: started …

Read more

  (Page 1 / 2)  Next