Provisioning Flashcards

1
Q

What is provisioning?

A

Automatic configuration of a server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What criteria should a good provisioning script respect?

A
  • Work from the first try.
  • Work when launched several times.
  • Be easy to understand, so be simple.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of a provisioning script?

A
  • Configure servers faster.
  • Avoid human errors.
  • Have a maintanable and reusable script.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where do we use a provisiong script?

A

On local VMs and remote servers hosting our applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Ansible? Are there alternatives?

A

Ansible is software that automates software provisioning, configuration management, and application deployment. Basically: write code to configure servers. Existing alternatives: Puppet, Chef, Bash scripts…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why Ansible does not require any additional software to be installed on client computers?

A

Because Ansible communicates over normal SSH channels in order to retrieve information from remote machines, issue commands, and copy files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which computers can be administered through Ansible?

A

Any computer (server) that has an SSH port exposed can be brought under Ansible’s configuration umbrella, regardless of what stage it is at in its life cycle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does Ansible work?

A

Ansible works by configuring client machines from an computer with Ansible components installed and configured.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does Ansible interact?

A

Ansible can interact with clients through either command line tools or through its configuration scripts called Playbooks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are written Ansible modules and configuration files?

A
  • Modules can be written in any language and communicate in standard JSON.
  • Configuration files are mainly written in the YAML data serialization format due to its expressive nature and its similarity to popular markup languages.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the best way to install Ansible on Ubuntu 16.04?

A
  • $ sudo apt-add-repository ppa:ansible/ansible
  • $ sudo apt-get update
  • $ sudo apt-get install ansible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does Ansible keep track of all the servers?

A

Through a hosts file (in /etc/ansible/hosts) that need to be set up before computers can communicate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to configure the hosts file so that Ansible can communicate with the servers via ssh?

A

Write in etc/ansible/hosts:

[group_name]

[alias] ansible_host=[server_IP] ansible_port=[port_number] ansible_user=[user]

For Ansible > 2.2: add ansible_python_interpreter=/usr/bin/python3

Optionally: use group specific variables by creating the group_vars directory in etc/ansible and then creating files with the format:

etc/ansible/group_vars/[group_name]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to make sure that Ansible has a connection to its hosts?

A
  • One host: $ ansible -m ping [server_alias]
  • Multiple hosts: $ ansible -m ping [server_alias]:[server_alias]
  • Group of hosts: $ ansible -m ping [group_name]
  • All hosts: $ ansible -m ping all
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are Ansible playbooks?

A
  • Ansible playbooks are a way to send commands to remote computers in a scripted way. That is, you can configure entire complex environments by passing a script to one or more systems.
  • Ansible playbooks are written in the YAML data serialization format.
  • Each playbook contains one or more plays, which map hosts to a certain function. Ansible does this through something called tasks, which are basically module calls.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between a standard YAML file and an Ansible YAML file?

A

YAML allows multiple “documents” to exist in one file, each seperated by —, but Ansible only wants one per file, present at the top of the file.

17
Q

What are the characteristics of YAML files?

A
  • YAML documents basically define a hierarchical tree structure with the containing elements further to the left.
  • A document starts with —.
  • YAML is very-sensitive to white-space:
    • Use only spaces.
    • The spacing should be consistent.
  • Items that begin with a - are considered list items.
  • Items with the format key: value operate as hashes or dictionaries.
18
Q

What are Ansible plays?

A

YAML items at the left-most level. Plays are groups of tasks performed on a certain set of hosts to allow them to fulfill the function you assign them.

Basic format:

  • hosts: [hostname_or_group]

tasks:

  • task 1
  • task 2
19
Q

What is the structure of an Ansible task?

A
  • name: [task_description]

[ansible_module]

[ansible_module]

20
Q

Simple description of the apt module.

A

​apt: pkg=[package] state=[state] update_cache=[true/false]

  • [state] can be present.
  • update-cache=true tells the remote computer to update its package cache prior to the state action.
21
Q

Simple description of the notify module.

A

The notify item can contain a list of references to handlers, which can perform certain functions when called from within a task.

Format:

notify:

  • [handler_name]
22
Q

What are Ansible handlers?

A
  • The “handlers” section exists at the same level as “hosts” and “tasks”.
  • Handlers are tasks that only run when they have been told to by task that changes have occured on the client system.
23
Q

How to run an Ansible playbook?

A
  • Only on the defined hosts:
    • $ ansible-playbook [playbook]
  • Filtering to specific hosts:
    • $ ansible-playbook -l [host_subset] [playbook]
      *
24
Q

How to check whether an Ansible action was successful or not?

A
  • Use the register module to register a task result (failure or success) in a variable that we can check later on.
  • When using this functionality, we also have to tell Ansible to ignore errors for that task, otherwise it will abort the playbook execution in case of an error.
  • Format:
  • name: …

command

register: [var]

ignore_errors: True

  • name: …

command

when: [var] | success
- name: …

command

when: [var] | failed

25
Q

How to execute a task or playbook as another user?

A
  • Use “become”, which can be set from play to task level, but is overridden by connection variables as they can be host specific.
  • become: true ==> activite privilege escalation.
  • become_user=[username] ==> defines the user used for privilege escalation. Default is root. become_user is useless if become is not set to true.