Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Testing ansible roles with molecule

1,500 views

Published on

Testing Ansible roles with Molecule.

Published in: Internet
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/K5WNN ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hey guys! Who wants to chat with me? More photos with me here 👉 http://www.bit.ly/katekoxx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Testing ansible roles with molecule

  1. 1. Testing Ansible roles with Molecule Werner Dijkerman, Nieuwegein, 17-05-2017
  2. 2. Confidential and Business Information The information contained herein is confidential information regarding the business of iWelcome BV and may include confidential information regarding its associated entities and other 3rd Parties. By accepting this document and the information provided therein, the recipient agrees that it will, cause its directors, officers, employees and representatives to, use such information discrete and exclusively for the purpose it is intended to be used for. None of the information may be divulged to any other party or reproduced, in whole or in part, without the express prior written permission of iWelcome. iWelcome is a registered trademark of iWelcome BV. 2
  3. 3. 3 Contents 1. Introduction 1. me 2. iWelcome 3. Why testing 2. Molecule v1 3. Molecule v2 4. Walkthrough
  4. 4. 4 Introduction - name: Werner Dijkerman work: title: System Engineer (Engineering) employer: iWelcome contact: - @djwasabiman - www.werner-dijkerman.nl other: technical_reviewer: - Zabbix Network Monitoring 2nd (Packt Pub, book) - Learning Docker 2nd (Packt Pub, book) - Advanced IT Automation with Ansible 2 (Packt Pub, Video) cats: True
  5. 5. 5 Identity & Access Management (‘IAM’):
 
 The ICT infrastructure required to provide & manage the right access for the right people, at the right place, on the right device to the right IT- services, and to do that in a safe, simple, cost- efficient and controllable manner.
 
 
 IDaaS: 100% delivered as a cloud service
  6. 6. 6 Selection of blue chip customers using iWelcome IDaaS for Workforce and / or CIAM use cases
  7. 7. 7 Introduction o Why do we test Ansible roles? Does the role do what it needs to do: • Is it installing the application(s)? • Is it configuring the correct templates? • Is the service(s) running? • etc
  8. 8. 8 Introduction What do we get for testing roles: Improving reliability: • We get more confidence and see that it works • Run the tests when Pull Requests are created Better quality: • Add functionality and/or tests
  9. 9. 9 Molecule v1 “Molecule is designed to aid in the development and testing of Ansible roles including support for multiple instances, operating system distributions, virtualization providers and test frameworks.” pip install molecule https://github.com/metacloud/molecule https://molecule.readthedocs.io/
  10. 10. 10 Molecule v1 Drivers: • Vagrant (Default) • OpenStack • Docker New Ansible role: molecule init --driver docker --role <role_name> When you already have a role: molecule init --driver docker https://molecule.readthedocs.io/en/stable-1.24/driver/index.html
  11. 11. 11 Molecule v1 o Providers (Specific to driver: Vagrant) • Virtualbox (Default) • Libvrt • Parallels • VMware Fusion https://molecule.readthedocs.io/en/stable-1.24/provider/ index.html
  12. 12. 12 Molecule v1 o Verifiers Used for the validation/testing of the role. • TestInfra (Default) • ServerSpec • Goss https://molecule.readthedocs.io/en/stable-1.24/verifier.html
  13. 13. 13 Molecule v1 o Molecule subcommands • molecule login ( --host <instance_name> ) • molecule syntax • molecule create • molecule converge • molecule idempotence • molecule verify • ansible-lint • flake • Testinfra / Serverspec / Goss • molecule destroy All can be done with the subcommand: molecule test
  14. 14. 14 Molecule v1 Ansible role dependencies Ansible configuration Molecule configuration Docker driver Verifier configuration molecule.yml
  15. 15. 15 Molecule v2 Molecule v2 • Ansible lint has own sub command • Docker (Default driver) • Using Scenarios! http://molecule.readthedocs.io/en/v2/
  16. 16. 16 Molecule v2 http://molecule.readthedocs.io/en/v2/configuration.html#scenario
  17. 17. 17 Walkthrough Using SystemD https://github.com/dj-wasabi/ansible-zabbix-agent/blob/master/ molecule.yml#L26
  18. 18. 18 Walkthrough Using group_vars https://github.com/dj-wasabi/ansible-zabbix-server/blob/ master/molecule.yml#L16
  19. 19. 19 Walkthrough Multiple instances like running a cluster molecule.yml playbook.yml
  20. 20. 20 Walkthrough Execution of role depends on other service https://github.com/dj-wasabi/ansible-ossec-agent/blob/ master/playbook.yml
  21. 21. 21 Walkthrough TestInfra check per distribution https://github.com/dj-wasabi/ansible-zabbix-server/blob/ master/tests/test_default.py#L63
  22. 22. Thank you for your attention!

×