Skip to content

Ansible playbook to implement "ansible-pull" with simple Git clone and ansible-playbook commands

License

Notifications You must be signed in to change notification settings

SharkPunch/simple-pull

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Pull

A similar to ansible-pull Ansible role, implemented with git clone and ansible-playbook commands.

Need for this was because ansible-pull doesn't support downloading playbook dependencies from Galaxy before running the playbook. This playbook might become unnecessary when ansible-pull support it.

Originally based on Stouts.pull, the playbook started to look so much different that I decided to split it to it's own playbook.

The role allows you to setup easily automatic updates for your server with simple-pull.

  • Install and configure simple-pull;
  • Setup SSH hosts and keys;
  • Follow repositories and run ansible playbooks;
  • Rotate logs;

Variables

pull_enabled: yes                       # The role is enabled
pull_install_ansible: yes               # Should this playbook install Ansible

pull_ansible_ppa: ppa:rquillo/ansible   # Ansible ppa repository

pull_user: "{{ansible_ssh_user}}"       # Run from user
pull_group: "{{pull_user}}"
pull_user_ssh_home: ~{{pull_user}}/.ssh

pull_prefix: /opt/ansible-pull          # Prefix directory
pull_logdir: "{{pull_prefix}}/var/log"  # Directory where logs will be stored
pull_workdir: "{{pull_prefix}}/etc/ansible-pull"   # Directory where jobs will be runned

pull_fingerprints:
- "bitbucket.org,131.103.20.167 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw=="
- "github.com,204.232.175.90 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="

pull_private_keys: []                   # The keys will be copied to server
pull_schedule: '*/15 * * * *'           # Schedule crontab

pull_sources: []                        # Define your sources to control
                                        # Ex: pull_sources:
                                        #     - name: myproject
                                        #       repo: [email protected]:Stouts/Django-application.git
                                        #       version: develop
                                        #       playbook: deploy/playbook.yml
                                        #       vars:
                                        #         custom_var: value
# Default values
pull_playbook:                          # Set to related path to main playbook file
pull_extra_vars: {}                     # Extra variables for pull
                                        # Ex. pull_extra_vars:
                                        #       version: 1.2
pull_repo:
pull_version: "HEAD"
pull_only_if_changed: no
pull_inventory:                         # Inventory hosts (each line will be addded to inventory as is)
- "{{inventory_hostname}} ansible_ssh_host=127.0.0.1"
pull_verbose: v

pull_mail_to: ""                        # Set to enable notifications about errors

Usage

Add simple-pull to your roles and set vars in your playbook file.

Example:

- hosts: all

  roles:
  - simple-pull

  vars:
    pull_user: vagrant
    pull_schedule: "* * * * *"      # Cron schedule
    pull_private_keys:              # The key will be copied on server
    - "{{inventory_dir}}/keys/deploy"

    # Followed repositories
    pull_sources:
    - name: myproject
      repo: [email protected]:Stouts/Django-application.git
      version: develop
      playbook: deploy/playbook.yml
      vars:
        custom_var: value

License

Licensed under the MIT License. See the LICENSE file for details.

Feedback, bug-reports, requests, ...

Are welcome!

About

Ansible playbook to implement "ansible-pull" with simple Git clone and ansible-playbook commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 92.6%
  • Makefile 7.4%