Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6594566
Fix broken molecule test on older Travis CI default Docker version.
geerlingguy Aug 12, 2020
583d2cb
Fixes #314: Explicitly define 'mode' for web page molecule example.
geerlingguy Aug 14, 2020
6c0ea31
Don't use sudo with pip3 installs in test environments.
geerlingguy Aug 31, 2020
28c2b5f
Attempt to fix pip3 installs of ansible and molecule.
geerlingguy Aug 31, 2020
281b96b
Try manually installing wheel for molecule Travis CI test.
geerlingguy Aug 31, 2020
1933758
Update build environment to focal fossa.
geerlingguy Aug 31, 2020
5f2aee8
Test if molecule[docker] works correctly.
geerlingguy Sep 11, 2020
a11484d
Merge branch 'test-molecule-deps' into master
geerlingguy Sep 11, 2020
d7365df
Make sure apt caches are updated more frequently for deployments and …
geerlingguy Sep 23, 2020
deae307
Bump Elasticsearch role requirement version.
geerlingguy Sep 28, 2020
4492e96
Fix broken test build due to molecule docker dependency missing.
geerlingguy Oct 16, 2020
50913b6
Switch from travis-ci.org to travis-ci.com.
geerlingguy Oct 27, 2020
12259fb
Issue #359: Convert tests to use GitHub Actions for CI.
geerlingguy Dec 8, 2020
3a24b6f
Minor tweaks to naming things.
geerlingguy Dec 8, 2020
ff701b4
Issue #359: Disable currently-failing test.
geerlingguy Dec 8, 2020
fc55174
Issue #359: Disable failing Jenkins test.
geerlingguy Dec 8, 2020
8929b08
Issue #359: Disable includes.yml Drupal install playbook due to failu…
geerlingguy Dec 8, 2020
28d7e83
Merge pull request #360 from geerlingguy/359-ci-to-gh-actions
geerlingguy Dec 8, 2020
05cce29
Add TinyPilot as a proud sponsor of geerlingguy
mtlynch Jan 14, 2021
43fbe5c
Merge pull request #375 from mtlynch/tinypilot-sponsor
geerlingguy Jan 14, 2021
333a83b
PR #375: Added note about GitHub sponsors to new sponsor section.
geerlingguy Jan 14, 2021
ef08acc
add cn readme.md
martinliu Jan 29, 2021
f9a7813
added short description
martinliu Jan 29, 2021
0eb85f8
add chinese steps.
martinliu May 1, 2021
7b8c4dc
finished ch3
martinliu May 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 118 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,135 @@ name: CI
push:
branches:
- master
schedule:
- cron: "10 2 * * 0"

jobs:
scripts:
name: Scripts
runs-on: ubuntu-latest
strategy:
matrix:
include:
- test_script: collection
- test_script: molecule
- test_script: orchestration

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.x'

test:
name: Molecule
- name: Run test script.
run: tests/${{ matrix.test_script }}.sh

playbooks:
name: Playbooks
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- centos8
- debian10
include:
- playbook: deployments.yml
distro: ubuntu2004
test_idempotence: false

# TODO: Not easy to test in CI at this time.
# - playbook: deployments-balancer.yml
# distro: ubuntu2004

# TODO: This started failing on GitHub Actions.
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
# - playbook: deployments-rolling.yml
# distro: ubuntu2004

- playbook: docker.yml
distro: ubuntu2004
test_idempotence: false

- playbook: docker-flask.yml
distro: ubuntu2004
test_idempotence: false

- playbook: docker-hubot.yml
distro: ubuntu2004
test_idempotence: false

- playbook: drupal.yml
distro: ubuntu2004

# TODO: Not easy to test in CI at this time.
# - playbook: dynamic-inventory.yml
# distro: ubuntu2004

- playbook: elk.yml
distro: ubuntu2004

- playbook: first-ansible-playbook.yml
distro: centos7

- playbook: galaxy-role-servers.yml
distro: ubuntu2004

# TODO: Not easy to test in CI at this time.
# - playbook: gluster.yml
# distro: ubuntu2004

- playbook: https-self-signed.yml
distro: ubuntu2004

- playbook: https-nginx-proxy.yml
distro: debian10

# TODO: This started failing on GitHub Actions.
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
# - playbook: includes.yml
# distro: ubuntu2004

# TODO: This started failing on GitHub Actions.
# See: https://github.com/geerlingguy/ansible-for-devops/issues/359
# - playbook: jenkins.yml
# distro: ubuntu2004

# TODO: Not easy to test in CI at this time.
# - playbook: kubernetes.yml
# distro: debian9

# TODO: Not easy to test in CI at this time.
# - playbook: lamp-infrastructure.yml
# distro: ubuntu2004

- playbook: nodejs.yml
distro: centos7

- playbook: nodejs-role.yml
distro: centos7

- playbook: security.yml
distro: centos8

- playbook: solr.yml
distro: ubuntu2004

- playbook: test-plugin.yml
distro: centos7

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Python 3.
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install molecule docker yamllint ansible-lint
- name: Download test shim.
run: |
wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
chmod +x tests/test.sh

- name: Run Molecule tests.
run: molecule test
- name: Run playbook with test shim.
run: tests/test.sh
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
working-directory: molecule
playbook: ${{ matrix.playbook }}
distro: ${{ matrix.distro }}
test_idempotence: ${{ matrix.test_idempotence }}
38 changes: 38 additions & 0 deletions .github/workflows/molecule-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Molecule CI
'on':
pull_request:
push:
branches:
- master

jobs:

test:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- centos8
- debian10

steps:
- name: Check out the codebase.
uses: actions/checkout@v2

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install molecule[docker] yamllint ansible-lint

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
working-directory: molecule
109 changes: 0 additions & 109 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible for DevOps Examples

[![Build Status](https://travis-ci.org/geerlingguy/ansible-for-devops.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-for-devops) [![GitHub CI](https://github.com/geerlingguy/ansible-for-devops/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/ansible-for-devops/actions)
[![CI](https://github.com/geerlingguy/ansible-for-devops/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-for-devops/actions?query=workflow%3ACI) [![Molecule CI](https://github.com/geerlingguy/ansible-for-devops/workflows/Molecule%20CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-for-devops/actions?query=workflow%3A%22Molecule+CI%22)

This repository contains Ansible examples developed to support different sections of [Ansible for DevOps](https://www.ansiblefordevops.com/), a book on [Ansible](http://www.ansible.com/) by [Jeff Geerling](https://www.jeffgeerling.com/).

Expand Down Expand Up @@ -72,7 +72,7 @@ Here is an outline of all the examples contained in this repository, by chapter:
### Chapter 13

- [`molecule`](molecule/): A Molecule example used for testing and developing an Ansible playbook, or for testing in a Continuous Integration (CI) environment.
- [`ci.yml` GitHub Actions workflow](.github/workflows/ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.
- [`molecule-ci.yml` GitHub Actions workflow](.github/workflows/molecule-ci.yml): A GitHub Actions workflow which runs the `molecule` example in a CI environment.

### Chapter 14

Expand All @@ -94,6 +94,12 @@ Here is an outline of all the examples contained in this repository, by chapter:

MIT

## Sponsors

* [TinyPilot](https://tinypilotkvm.com): An open-source, low-cost KVM over IP for managing your servers.

The above sponsor is [sponsoring Jeff Geerling on GitHub Sponsors](https://github.com/sponsors/geerlingguy). You can sponsor Jeff's work too, to help him continue improving this book and Ansible open source work!

## Buy the Book

[![Ansible for DevOps Cover](https://s3.amazonaws.com/titlepages.leanpub.com/ansible-for-devops/medium)](https://www.ansiblefordevops.com/)
Expand Down
2 changes: 1 addition & 1 deletion elk/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ roles:
- name: geerlingguy.nginx
- name: geerlingguy.pip
- name: geerlingguy.elasticsearch
version: 4.1.1
version: 5.0.0
- name: geerlingguy.elasticsearch-curator
version: 2.1.0
- name: geerlingguy.kibana
Expand Down
58 changes: 58 additions & 0 deletions first-ansible-playbook/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 第一个 Ansible Playbook 演示虚拟机

这个项目创建一个虚拟机,并演示了一个非常简单的 Ansible Playbook。

## 快速入门指南

### 1 - 安装依赖关系(VirtualBox, Vagrant, Ansible)。

1. 下载并安装【VirtualBox】(https://www.virtualbox.org/wiki/Downloads)。
2. 下载并安装 [Vagrant](http://www.vagrantup.com/downloads.html)。
3. [仅限 Mac/Linux]安装[Ansible](http://docs.ansible.com/intro_installation.html)。

Windows请用户注意。*本指南假设您使用的是Mac或Linux主机。目前不支持Windows主机。如报错请自行调试。*

### 2 - 构建虚拟机

1. 下载这个项目,并把它放在你想放的地方。
2. 打开终端,cd 到这个目录。
4. 4.输入`vagrant up`,让Vagrant发挥它的魔力。

注意: *如果在运行`vagrant up`的过程中出现任何错误,并且它让你回到命令提示符,只需运行`vagrant provision`继续从你离开的地方构建虚拟机。如果这样做了几次之后仍然有错误,请在GitHub上的项目问题队列中发布一个问题,并注明错误。*

### 3 - 代码说明

```yml
---
- hosts: all # 执行所有目标 host
become: yes # 提升管理员权限

tasks:
- name: Ensure chrony (for time synchronization) is installed.
yum: # 软件包管理
name: chrony
state: present #存在

- name: Ensure chrony is running.
service: # 系统服务管理
name: chronyd
state: started #启动服务
enabled: yes # 开机启动

# The same as the above play, but in super-compact form!
# 这是超级简洁的无废话代码,功能和上面的代码一样
- hosts: all
become: yes
tasks:
- yum: name=chrony state=present
- service: name=chronyd state=started enabled=yes
```


## 注意

- 要关闭虚拟机,在终端中输入 "vagrant halt",在同一个文件夹中输入 "Vagrantfile"。要完全销毁它(如果你想节省一点磁盘空间,或者想用 "vagrant up "从头开始重建),输入 "vagrant destroy"。

## 关于作者

这个项目是由[Jeff Geerling](https://www.jeffgeerling.com/)创建的,作为[Ansible for DevOps](https://www.ansiblefordevops.com/)的一个例子。
Loading