Giter VIP home page Giter VIP logo

ansible-role-createtag's Introduction

createtag

A role to create a git tag in a repo and push it to the specified remote.

Requirements

Git must be installed on any host that will run this role.

Role Variables

git_repo_location: the path to the git repo, defaults to '.'
git_remote: remote to push to, defaults to 'origin', set to null to not push.
git_tag: the tag to apply, use templating to make it sensible!
skip_if_tag_matching: see 'Conditional Tagging' below.
update_git_tag: See 'Updating Tags' below. Defauts to false.

Dependencies

None.

Example Playbook

This will create a tag something like qa-2016-06-19, assuming env is defined somewhere, such as in your inventory file:

- hosts: localhost
  vars:
    git_tag: "{{env}}-{{ansible_date_time.date}}"
  roles:
    - cjw296.createtag

Conditional Tagging

If you have a daily release process that pushes the HEAD of a branch to a testing environment, you may find that this role creates a lot of tags on a commit that ends up being HEAD for a number of weeks.

To prevent that, you can set skip_if_tag_matching to a glob such that each commit will only be tagged the first time it is released to a particular environment.

Modifying the above example, this gives:

- hosts: localhost
  vars:
    git_tag: "{{env}}-{{ansible_date_time.date}}"
    skip_if_tag_matching: "{{env}}*"
  roles:
    - cjw296.createtag

Updating Tags

Sometimes you just want a simple tag marking which commit has been sent to an environment, and then have that tag moved each time you do a release.

To achieve this, working with the above example would become:

- hosts: localhost
  vars:
    git_tag: "{{env}}"
    update_git_tag: true
  roles:
    - cjw296.createtag

License

MIT

Author Information

Chris Withers [email protected]

ansible-role-createtag's People

Contributors

cjw296 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.