sixarm_ansible_examples

SixArm.com » Ansible examples of configuration files

https://github.com/sixarm/sixarm_ansible_examples

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.9%) to scientific vocabulary

Keywords

ansible configuration examples
Last synced: 6 months ago · JSON representation ·

Repository

SixArm.com » Ansible examples of configuration files

Basic Info
  • Host: GitHub
  • Owner: SixArm
  • Default Branch: main
  • Size: 29.3 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
ansible configuration examples
Created about 10 years ago · Last pushed 10 months ago
Metadata Files
Readme Contributing Code of conduct Citation Codeowners

README.md

SixArm.com »
Ansible examples of configuration files.

Contents:

Start

Verify Ansible runs and its version is at least 2.1:

$ ansible --version
2.1.0.0

Run a simple command:

$ ansible all -i localhost, -c local -m shell -a 'echo hello world'
localhost | SUCCESS | rc=0 >>
hello world

Clone this repo and go into it:

$ git clone https://github.com/sixarm/sixarm_ansible_examples
$ cd //github.com/sixarm/sixarm_ansible_examples

Ansible playbooks and tasks

This repository is oriented toward playbooks and tasks.

See the playbooks directory and tasks directory.

One playbook corresponds to one task. This is because Ansible currently can run one playbook, but cannot run one task without a playbook.

Run a simple playbook:

$ ansible-playbook -i localhost, -c local playbooks/hello-world.yml

PLAY [Hello World] ***********************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [include] *****************************************************************
included: tasks/hello-world.yml for localhost

TASK [Hello World] ***********************************************************
ok: [localhost] => {
  "msg": "Hello World"
}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

Host file

We typically use a host file, even when we are simply doing command line one-off scripts, because we like to have the flexibility of using multiple hostnames and multiple settings.

Create a host file with this text:

localhost

Now you can use the host file like this:

$ ansible-playbook -i host -c local playbooks/hello-world.yml

Output

Ansible does not print the result of commands. Instead, an Ansible script can register a variable that receives the output, and then a subsequent task can print the output by using the debug module.

Example task:

- name: demo
  command: which python
  register: x
- debug: var=x.stdout_lines

Run a playbook to print the current python interpreter path:

$ ansible-playbook -i host -c local playbooks/which-python.yml
…
ok: [localhost] => {
    "x.stdout_lines": [
        "/usr/local/bin/python"
    ]
}

Privilege escalation

Ansible documentation strongly recommends against setting any sudo password in plaintext, and instead using the command line option --ask-become-pass abbreviated -K. This option used to be called --ask-sudo-pass.

Run a playbook that uses the "become" setting, which does privilege escalation akin to the sudo command:

$ ansible-playbook -K -i host -c local playbooks/demo-become.yml
SUDO password:
…

Another way to accomplish privilege escalation is to create a user on the target machine, then grant the user passwordless sudo privileges to either all commands or a restricted list of commands.

Run sudo visudo and enter a line like the below:

%alice ALL= NOPASSWD: /usr/bin/service

The line means the user 'alice' does not enter a password when they run something like sudo service xxxx start.

Another way to accomplish privilege escalation is to create an Ansible vault:

ansible-vault create myvault

For more info see http://stackoverflow.com/questions/21870083/specify-sudo-password-for-ansible

Boto 3 - The AWS SDK for Python

Some Ansible modules use the python 2.x language and the Boto Amazon Web Services (AWS) Software Development Kit (SDK).

Boto documentation: http://boto3.readthedocs.io/en/latest/

To install boto typically:

$ pip install boto

If you get this kind of error:

fatal: [localhost]:
FAILED! => {
  "changed": false,
  "failed": true,
  "msg": "boto required for this module, install via pip or your package manager"
}

Then you need to tell Ansible how to find the python interpreter and the boto package.

To tell Ansible how to find the python interpreter, we prefer using the host file like this:

localhost ansible_python_interpreter="/usr/bin/env python"

Sidenote: to install boto3 globally to your system using python3, one way is to do is:

$ sudo su -
$ cd /opt
$ git clone https://github.com/boto/boto3
$ cd boto3
$ python3 setup.py install

Owner

  • Name: SixArm
  • Login: SixArm
  • Kind: organization
  • Email: sixarm@sixarm.com
  • Location: San Francisco

SixArm Software

Citation (CITATION.cff)

cff-version: 1.2.0
title: SixArm.com » <br> Ansible examples of configuration files.
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/SixArm/sixarm_ansible_examples/'
    description: SixArm.com » <br> Ansible examples of configuration files.
repository-code: 'https://github.com/SixArm/sixarm_ansible_examples/'
abstract: >-
  SixArm.com » <br> Ansible examples of configuration files.
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 42
  • Total Committers: 1
  • Avg Commits per committer: 42.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 42
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels