Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ansible with with Molecule
Search
Markus Hanses
February 28, 2019
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ansible with with Molecule
Markus Hanses
February 28, 2019
More Decks by Markus Hanses
See All by Markus Hanses
DomainDriven Design - An Overview
markushanses
0
2.1k
Apache Zeppelin Tutorial
markushanses
0
480
Git - shared insights
markushanses
0
91
Spock configuration variants
markushanses
0
340
Spock.Code.Week
markushanses
0
140
Kontinuierliches Refactoring
markushanses
0
1.1k
TDD Coding Dojo
markushanses
0
630
TDD Code-Kata - Eine Einführung
markushanses
0
580
Other Decks in Programming
See All in Programming
新卒PdEのリアル
ryu1013
1
520
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
130
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
530
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
280
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.4k
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
18
17k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
370
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
7
4.9k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
320
Webの地図
yosuke_furukawa
PRO
6
4.8k
速習iPhone Duo対応
yuukiw00w
2
840
Security issues being discussed on Web Platforms
petamoriken
0
1.2k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Building AI with AI
inesmontani
PRO
1
1.3k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Ruling the World: When Life Gets Gamed
codingconduct
0
360
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
66k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Transcript
Ansible Testing with Molecule
Advantages • Quality gate for Infrastructure as Code • Isolated
test environment • Early feedback during development • Fail fast before application in real systems • Encourages separation of concerns in Ansible Roles
Python setup with pyenv
Create your Environment $> virtualenv project/venv # creates env $>
source project/venv/bin/activate # activates env $> deactivate # deactivates env
Install Molecule $> pip install molecule ansible $> pip docker
# virtualization driver
Create new Ansible role $> molecule init role --role-name user.rolename
-d docker $> molecule init role -r user.rolename -d docker # choose driver from one below... # azure, docker, ec2, gce, lxc, lxd, openstack, vagrant, # delegated
Add Molecule to existing Ansible role $> ansible-galaxy init user.rolename
$> cd user.rolename $> molecule init scenario -r user.rolename
Add new scenarios to Molecule $> molecule init scenario \
# long --scenario-name special \ -r user.rolename $> molecule init scenario \ # short -s special \ -r user.rolename
Molecule configurations • Test run ◦ molecule.yml # Molecule configuration
file ◦ playbook.yml # Test case definition • Syntax checks ◦ yamllint # Linter for Yaml files / Ansible, Molecole ◦ flake8 # Linter for Python code / Testinfra ◦ ansible-lint # Linter for Ansible playbooks
Molecule test run $> molecule test # bare metal $>
docker run --rm -it \ # docker -v '$(pwd)':/tmp/$(basename "${PWD}"):ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -w /tmp/$(basename "${PWD}") \ retr0h/molecule:latest \ sudo molecule test
Molecule test matrix └── default ├── lint # flake8, yamllint,
ansible-lint syntax check ├── destroy # deletes pre-existing containers ├── dependency # installs python dependencies ├── syntax # Playbook syntax check ├── create # creates the docker container ├── prepare # prepares the docker container / pre-configuration ├── converge # executes the test playbook ├── idempotence # executes the test playbook a second time ├── side_effect # Occurs additional effects to the environment ├── verify # executes the Testinfra tests └── destroy # deletes new containers
Demo Time • IaC sample project • From scratch
end of presentation Author Markus Hanses Date 2019-03-02
Sources • pyenv, https://github.com/pyenv/pyenv • Virtualenv, https://docs.python-guide.org/dev/virtualenvs/ • Molecule, https://molecule.readthedocs.io/en/latest/index.html
• Testinfra, https://testinfra.readthedocs.io/en/latest/# • flake8, http://flake8.pycqa.org/en/latest/ • yamllint, https://yamllint.readthedocs.io/en/stable/ • ansible-lint, https://github.com/ansible/ansible-lint • Digital Ocean Blog Post, http://bit.do/eJXD3 • Demo project, https://github.com/marhan/ansible-role-fail2ban • Demo pipeline, https://travis-ci.org/marhan/ansible-role-fail2ban