Skip to content

Example repository used for demo purposes - contains Ansible playbooks and uses a requirements.yml to pull Ansible Roles

License

Notifications You must be signed in to change notification settings

ansiblejunky/ansible-project-template

Repository files navigation

Ansible Project Template

This repository is a template for an Ansible Project that includes the typical Ansible structure.

  • .config folder contains lint rules and other configuration
  • .github folder contains GitHub workflow action configuration
  • collections folder contains definitions of Ansible Collections
  • roles folder contains definitions of Ansible Roles
  • hosts folder contains Ansible inventory and configuration management with group variables
  • plugins folder contains custom Ansible plugins for inventory, filter, action, callback, and so on
  • playbooks folder contains Ansible Playbooks to perform actions
  • Continuous Testing is performed using various linting tools
    • Ansible Lint
    • Flake8 for Python linting
    • PyLint for Python linting

Running Playbooks

Using Ansible Playbook:

ansible-playbook -i hosts/dev/inventory playbooks/example.yml

Using Ansible Navigator:

TODO: Add command using latest EE image

Using Ansible Automation Platform (AAP):

TODO: Create a playbook to create objects in AAP!

  • Create a new Project pointing to the Ansible Project version control repo
  • Create a new Inventory
  • Create a new Inventory Source in the new Inventory object you created
    • Select "Source from a Project"
    • Select the Project you created
    • Select the inventory file as the source
  • Synchronize the Inventory Source to make sure it succeeds
  • Notice now that your Inventory object contains the vars and hosts and groups from the inventory structure
  • Notice it loaded the variables from within the group_vars folder as well!
  • Create a new Job Template
    • Set the name
    • Set the Project
    • Set the Playbook
    • Set the Credentials

References

License

GNUv3

Author

John Wadleigh

TODO:

Ansible Framework:

Playbook:


  • hosts: localhost #connection: local

TODO: get the framework from HCSC that checks for Windows or Linux machine using port check!

(payload provided from external system)

tasks:

  • include_role: name: provision vars: os_string: "{{ item.os_string }}" ... with_items: "{{ buildlist }}" when: ansible_os_family == windows

  • include_role: name: provision vars: os_string: "{{ item.os_string }}" ... with_items: "{{ buildlist }}" when: ansible_os_family == linux

  • hosts: windows gather_facts: true

    tasks:

    • do things
  • hosts: linux gather_facts: true

    tasks:

    • do things

Ansible Role:

defaults/ main.yml tasks/ main.yml linux_do_something.yml windows_do_something.yml vars/ main.yml (platform agnostic vars) port: 80 linux.yml install_path: /opt/app windows.yml install_path: c:\sdjfk

main.yml:

  • include_tasks: "{{ ansible_os_family }}_do_something.yml"

About

Example repository used for demo purposes - contains Ansible playbooks and uses a requirements.yml to pull Ansible Roles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages