mirror of
https://github.com/geerlingguy/ansible-role-ansible.git
synced 2024-09-27 03:52:35 +02:00
Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a6839112ce | ||
|
c88ef477fa | ||
|
f28674d784 | ||
|
8c85339f21 | ||
|
470ad53d13 | ||
|
e9a19b1a79 | ||
|
e33397b43a | ||
|
b1d2710661 | ||
|
8a145319a3 | ||
|
ac2fc8372c | ||
|
e01427a892 | ||
|
e96ad2577f | ||
|
4ac86968ff | ||
|
d9d3fe3f39 | ||
|
ebb6b438ab | ||
|
4682745d1b | ||
|
e621f3b2f7 | ||
|
875a8f93b2 | ||
|
53b364606d | ||
|
25d8f5fc04 | ||
|
94b3532fb4 | ||
|
adf22d8c73 | ||
|
35546b1505 | ||
|
ba22aaeb41 | ||
|
409ec4b75a | ||
|
d600480d49 | ||
|
214fe648a4 | ||
|
25a7bf99f4 | ||
|
cc3093948d | ||
|
b063494796 | ||
|
00ff01ede6 | ||
|
d272377d9c | ||
|
1bf9093c36 | ||
|
c1e4227438 | ||
|
11eff5071a | ||
|
ff94bc2606 | ||
|
ab624458f9 | ||
|
bf8a54b24c | ||
|
31db496b33 | ||
|
931575ba3b | ||
|
dd8894d6e0 | ||
|
47f030f6c1 | ||
|
d5dec9f860 | ||
|
33a2d8ded7 | ||
|
c17bf5e903 | ||
|
480b3fe831 | ||
|
95963937d4 | ||
|
907eb7a247 | ||
|
c2e176a97d | ||
|
130efa010e | ||
|
cfeb18a90f |
3
.ansible-lint
Normal file
3
.ansible-lint
Normal file
@ -0,0 +1,3 @@
|
||||
skip_list:
|
||||
- 'yaml'
|
||||
- 'role-name'
|
4
.github/FUNDING.yml
vendored
Normal file
4
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
---
|
||||
github: geerlingguy
|
||||
patreon: geerlingguy
|
75
.github/workflows/ci.yml
vendored
Normal file
75
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
---
|
||||
name: CI
|
||||
'on':
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
- cron: "30 5 * * 0"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: 'geerlingguy.ansible'
|
||||
|
||||
jobs:
|
||||
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the codebase.
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'geerlingguy.ansible'
|
||||
|
||||
- name: Set up Python 3.
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install test dependencies.
|
||||
run: pip3 install yamllint
|
||||
|
||||
- name: Lint code.
|
||||
run: |
|
||||
yamllint .
|
||||
|
||||
molecule:
|
||||
name: Molecule
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- distro: rockylinux9
|
||||
playbook: converge.yml
|
||||
- distro: fedora39
|
||||
playbook: converge.yml
|
||||
- distro: ubuntu2204
|
||||
playbook: converge.yml
|
||||
- distro: debian12
|
||||
playbook: converge.yml
|
||||
- distro: rockylinux9
|
||||
playbook: pip.yml
|
||||
|
||||
steps:
|
||||
- name: Check out the codebase.
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'geerlingguy.ansible'
|
||||
|
||||
- name: Set up Python 3.
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install test dependencies.
|
||||
run: pip3 install ansible molecule molecule-plugins[docker] docker
|
||||
|
||||
- name: Run Molecule tests.
|
||||
run: molecule test
|
||||
env:
|
||||
PY_COLORS: '1'
|
||||
ANSIBLE_FORCE_COLOR: '1'
|
||||
MOLECULE_DISTRO: ${{ matrix.distro }}
|
||||
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
|
40
.github/workflows/release.yml
vendored
Normal file
40
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
|
||||
# repository or organization.
|
||||
#
|
||||
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
|
||||
# See: https://github.com/ansible/galaxy/issues/46
|
||||
|
||||
name: Release
|
||||
'on':
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: 'geerlingguy.ansible'
|
||||
|
||||
jobs:
|
||||
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the codebase.
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: 'geerlingguy.ansible'
|
||||
|
||||
- name: Set up Python 3.
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install Ansible.
|
||||
run: pip3 install ansible-core
|
||||
|
||||
- name: Trigger a new import on Galaxy.
|
||||
run: >-
|
||||
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }}
|
||||
$(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
|
34
.github/workflows/stale.yml
vendored
Normal file
34
.github/workflows/stale.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
name: Close inactive issues
|
||||
'on':
|
||||
schedule:
|
||||
- cron: "55 19 * * 1" # semi-random time
|
||||
|
||||
jobs:
|
||||
close-issues:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
days-before-stale: 120
|
||||
days-before-close: 60
|
||||
exempt-issue-labels: bug,pinned,security,planned
|
||||
exempt-pr-labels: bug,pinned,security,planned
|
||||
stale-issue-label: "stale"
|
||||
stale-pr-label: "stale"
|
||||
stale-issue-message: |
|
||||
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
|
||||
|
||||
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
|
||||
close-issue-message: |
|
||||
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
|
||||
stale-pr-message: |
|
||||
This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
|
||||
|
||||
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
|
||||
close-pr-message: |
|
||||
This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
*.retry
|
||||
tests/test.sh
|
||||
*/__pycache__
|
||||
*.pyc
|
||||
.cache
|
||||
|
||||
|
29
.travis.yml
29
.travis.yml
@ -1,29 +0,0 @@
|
||||
---
|
||||
services: docker
|
||||
|
||||
env:
|
||||
- distro: centos7
|
||||
- distro: centos6
|
||||
- distro: fedora27
|
||||
- distro: ubuntu1604
|
||||
- distro: ubuntu1404
|
||||
- distro: ubuntu1204
|
||||
- distro: debian8
|
||||
|
||||
script:
|
||||
# Configure test script so we can run extra tests after playbook is run.
|
||||
- export container_id=$(date +%s)
|
||||
- export cleanup=false
|
||||
|
||||
# Download test shim.
|
||||
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
|
||||
- chmod +x ${PWD}/tests/test.sh
|
||||
|
||||
# Run tests.
|
||||
- ${PWD}/tests/test.sh
|
||||
|
||||
# Ensure Ansible is installed (contrived... since it's already installed).
|
||||
- 'docker exec --tty ${container_id} env TERM=xterm ansible --version'
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
10
.yamllint
Normal file
10
.yamllint
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length:
|
||||
max: 120
|
||||
level: warning
|
||||
|
||||
ignore: |
|
||||
.github/workflows/stale.yml
|
44
README.md
44
README.md
@ -1,16 +1,37 @@
|
||||
# Ansible Role: Ansible
|
||||
|
||||
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-ansible.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-ansible)
|
||||
[![CI](https://github.com/geerlingguy/ansible-role-ansible/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-ansible/actions?query=workflow%3ACI)
|
||||
|
||||
An Ansible Role that installs Ansible on RHEL/CentOS and Debian/Ubuntu.
|
||||
An Ansible Role that installs Ansible on Linux servers.
|
||||
|
||||
## Requirements
|
||||
|
||||
If using on a RedHat/CentOS-based host, make sure you've added the EPEL repository (it can easily be installed by including the `geerlingguy.repo-epel` role on Ansible Galaxy).
|
||||
If using on a RedHat/CentOS/Rocky Linux-based host, make sure you've added the EPEL repository (it can easily be installed by including the `geerlingguy.repo-epel` role on Ansible Galaxy).
|
||||
|
||||
## Role Variables
|
||||
|
||||
None.
|
||||
Available variables are listed below, along with default values (see `defaults/main.yml`):
|
||||
|
||||
ansible_install_method: package
|
||||
|
||||
Whether to install Ansible via the system `package` manager (`apt`, `yum`, `dnf`, etc.), or via `pip`. If set to `pip`, you need to make sure Pip is installed prior to running this role. You can use the `geerlingguy.pip` module to install Pip easily.
|
||||
|
||||
ansible_install_version_pip: ''
|
||||
|
||||
If `ansible_install_method` is set to `pip`, the specific Ansible version to be installed via Pip. If not set, the latest version of Ansible will be installed.
|
||||
|
||||
ansible_install_pip_extra_args: ''
|
||||
|
||||
If `ansible_install_method` is set to `pip`, the extra arguments to be given to `pip` are listed here. If not set, no extra arguments are given.
|
||||
|
||||
ansible_pip_executable: ''
|
||||
|
||||
if `ansible_install_method` is set to `pip`, this is the path to the pip executable, in case your platform doesn't find the right name.
|
||||
|
||||
ansible_epel_repo_name: 'epel'
|
||||
|
||||
if `ansible_install_method` is set to `package` and you are on a RHEL machine, and your local satellite server admins decided to name the epel repository something other than epel, this variable gives you the opportunity to provide the right name.
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
@ -18,9 +39,22 @@ None.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
Install from the system package manager:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: geerlingguy.ansible }
|
||||
- role: geerlingguy.ansible
|
||||
|
||||
Install from pip:
|
||||
|
||||
- hosts: servers
|
||||
vars:
|
||||
ansible_install_method: pip
|
||||
ansible_install_version_pip: "8.6.0"
|
||||
ansible_install_pip_extra_args: "--user"
|
||||
roles:
|
||||
- role: geerlingguy.pip
|
||||
- role: geerlingguy.ansible
|
||||
|
||||
## License
|
||||
|
||||
|
17
defaults/main.yml
Normal file
17
defaults/main.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
ansible_default_release: ""
|
||||
|
||||
# Valid options include: 'package' or 'pip'.
|
||||
ansible_install_method: package
|
||||
|
||||
# Used only if ansible_install_method is 'pip'. If empty, defaults to latest.
|
||||
ansible_install_version_pip: ''
|
||||
|
||||
# Which extra arguments should be gived to pip
|
||||
ansible_install_pip_extra_args: ''
|
||||
|
||||
# path to pip executable to use
|
||||
ansible_pip_executable: ''
|
||||
|
||||
# name of epel repo if it isn't standard
|
||||
ansible_epel_repo_name: 'epel'
|
@ -6,12 +6,8 @@ galaxy_info:
|
||||
description: Ansible for RedHat/CentOS/Debian/Ubuntu.
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 2.0
|
||||
min_ansible_version: 2.10
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
@ -26,3 +22,5 @@ galaxy_info:
|
||||
- packaging
|
||||
- development
|
||||
- cloud
|
||||
- ansible
|
||||
- automation
|
||||
|
12
molecule/default/converge.yml
Normal file
12
molecule/default/converge.yml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
pre_tasks:
|
||||
- name: Update apt cache.
|
||||
apt: update_cache=true cache_valid_time=300
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
roles:
|
||||
- role: geerlingguy.ansible
|
21
molecule/default/molecule.yml
Normal file
21
molecule/default/molecule.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
role_name_check: 1
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
ignore-errors: true
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: instance
|
||||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest"
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
pre_build_image: true
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
|
14
molecule/default/pip.yml
Normal file
14
molecule/default/pip.yml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
vars:
|
||||
ansible_install_method: pip
|
||||
ansible_pip_executable: pip3
|
||||
ansible_install_version_pip: "8.6.0"
|
||||
ansible_install_pip_extra_args: "--user"
|
||||
|
||||
roles:
|
||||
- role: geerlingguy.pip
|
||||
- role: geerlingguy.ansible
|
2
molecule/default/requirements.yml
Normal file
2
molecule/default/requirements.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
- role: geerlingguy.pip
|
@ -1,13 +1,34 @@
|
||||
---
|
||||
- name: Set the package state based on how Ansible is installed.
|
||||
set_fact:
|
||||
ansible_package_state: "{{ 'present' if ansible_install_method == 'package' else 'absent' }}"
|
||||
|
||||
# Setup/install tasks.
|
||||
- include: setup-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora'
|
||||
- name: Set up Ansible on RedHat.
|
||||
include_tasks: setup-RedHat.yml
|
||||
when:
|
||||
- ansible_os_family == 'RedHat'
|
||||
- ansible_distribution != 'Fedora'
|
||||
- ansible_install_method == 'package'
|
||||
|
||||
- include: setup-Fedora.yml
|
||||
when: ansible_distribution == 'Fedora'
|
||||
- name: Set up Ansible on Fedora.
|
||||
include_tasks: setup-Fedora.yml
|
||||
when:
|
||||
- ansible_distribution == 'Fedora'
|
||||
- ansible_install_method == 'package'
|
||||
|
||||
- include: setup-Ubuntu.yml
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
- name: Set up Ansible on Ubuntu.
|
||||
include_tasks: setup-Ubuntu.yml
|
||||
when:
|
||||
- ansible_distribution == 'Ubuntu'
|
||||
- ansible_install_method == 'package'
|
||||
|
||||
- include: setup-Debian.yml
|
||||
when: ansible_distribution == 'Debian'
|
||||
- name: Set up Ansible on Debian.
|
||||
include_tasks: setup-Debian.yml
|
||||
when:
|
||||
- ansible_distribution == 'Debian'
|
||||
- ansible_install_method == 'package'
|
||||
|
||||
- name: Set up Ansible using Pip.
|
||||
include_tasks: setup-pip.yml
|
||||
when: ansible_install_method == 'pip'
|
||||
|
@ -1,15 +1,21 @@
|
||||
---
|
||||
- name: Enable Backports repository.
|
||||
apt_repository:
|
||||
repo: 'deb http://ftp.debian.org/debian {{ ansible_distribution_release }}-backports main'
|
||||
repo: >-
|
||||
deb http://ftp.debian.org/debian
|
||||
{{ ansible_distribution_release }}-backports main'
|
||||
state: present
|
||||
filename: "{{ ansible_distribution_release }}_backports"
|
||||
update_cache: true
|
||||
when: ansible_distribution_version | int < 9
|
||||
|
||||
- name: Update apt cache.
|
||||
apt: update_cache=yes cache_valid_time=86400
|
||||
- name: Set the default_release option for older Debian versions.
|
||||
set_fact:
|
||||
ansible_default_release: "{{ ansible_distribution_release }}-backports"
|
||||
when: ansible_distribution_version | int < 9
|
||||
|
||||
- name: Install Ansible.
|
||||
apt:
|
||||
name: ansible
|
||||
state: present
|
||||
default_release: "{{ ansible_distribution_release }}-backports"
|
||||
state: "{{ ansible_package_state }}"
|
||||
default_release: "{{ ansible_default_release }}"
|
||||
|
@ -1,3 +1,5 @@
|
||||
---
|
||||
- name: Install Ansible.
|
||||
package: name=ansible state=present
|
||||
package:
|
||||
name: ansible
|
||||
state: "{{ ansible_package_state }}"
|
||||
|
@ -1,3 +1,6 @@
|
||||
---
|
||||
- name: Install Ansible.
|
||||
yum: name=ansible state=present enablerepo=epel
|
||||
package:
|
||||
name: ansible
|
||||
state: "{{ ansible_package_state }}"
|
||||
enablerepo: "{{ ansible_epel_repo_name }}"
|
||||
|
@ -1,9 +1,15 @@
|
||||
---
|
||||
- name: Add ansible repository.
|
||||
apt_repository: repo='ppa:ansible/ansible'
|
||||
- name: Ensure dirmngr is installed (gnupg dependency).
|
||||
apt:
|
||||
name: dirmngr
|
||||
state: present
|
||||
|
||||
- name: Update apt cache.
|
||||
apt: update_cache=yes cache_valid_time=86400
|
||||
- name: Add ansible repository.
|
||||
apt_repository:
|
||||
repo: 'ppa:ansible/ansible'
|
||||
update_cache: true
|
||||
|
||||
- name: Install Ansible.
|
||||
apt: name=ansible state=present
|
||||
apt:
|
||||
name: ansible
|
||||
state: "{{ ansible_package_state }}"
|
||||
|
7
tasks/setup-pip.yml
Normal file
7
tasks/setup-pip.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Install Ansible via Pip.
|
||||
pip:
|
||||
name: ansible
|
||||
executable: "{{ ansible_pip_executable | default(omit) }}"
|
||||
version: "{{ ansible_install_version_pip | default(omit) }}"
|
||||
extra_args: "{{ ansible_install_pip_extra_args | default(omit) }}"
|
@ -1,13 +0,0 @@
|
||||
# Ansible Role tests
|
||||
|
||||
To run the test playbook(s) in this directory:
|
||||
|
||||
1. Install and start Docker.
|
||||
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
|
||||
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
|
||||
1. Make the test shim executable: `chmod +x tests/test.sh`.
|
||||
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
|
||||
|
||||
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`
|
||||
|
||||
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`
|
@ -1,5 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
roles:
|
||||
- role_under_test
|
Loading…
Reference in New Issue
Block a user