Code Monkey home page Code Monkey logo

ansible-role-golang's Introduction

Ansible Role: Go

Build Status stability-stable Ansible Galaxy MIT licensed

  • Installs the Google Go programming language
  • Install configurations are entirely automatic
  • Install configurations can be manually set
  • Installs from configurable mirror
  • Optionally cleans your $GOPATH whenever you need to.
  • Installs optional packages using go get and/or go install.

Requirements

None.

Role Variables

Installation configuration

go_custom_mirror: https://storage.googleapis.com/golang

Basic configuration

go_version: 1.10beta2
GOPATH: /home/vagrant/go
GOROOT: /usr/local/go
GOPROXY: https://proxy.golang.org

Optional configuration

GO111MODULE: "on" # Needs to be of type string, not on/off which will be handled as a boolean.
GOOS: darwin
GOARCH: amd64
go_checksum: sha256:82628a1a42d7ad88b100d0c4c9c0282a7e008e4eb73876bed4bd61ac4ee11b46

Building from source

Golang Bootstrap Workspace

GOROOT_BOOTSTRAP: /home/vagrant/go1.4

Boolean to indicate build should be from source.

build_go_from_source: false

Boolean to indicate Bootstrap needs installation.

install_go_bootstrap: false

Which script should be used when building from source

go_build_script: make.bash

To install go get binaries/projects, add them to go_get with any modules configuration as desired. By not specifying a value for modules, the installation will assume the value of GO111MODULE.

Default configuration without modules configuration:

go_get:
- name: golint
  url: github.com/golang/lint/golint

Configuration with modules disabled:

go_get:
- name: dvm
  url: github.com/fubarhouse/dvm
  modules: false

Configuration with modules enabled:

go_get:
- name: gopm
  url: github.com/gpmgo/gopm
  modules: true

You can also manually clone and get specific versions of packages, which does not include the download of any dependencies.

This was due to the need to install specific versions of software written in Go, and the language provides no alternative at this time.

It's highly recommend you run this playbook as many times as you need until you can get a success and to use go_reget in conjunction with this feature, or to not use this feature unless absolutely necessary.

go_install:
  # repo is the git clone url, ssh or https.
- repo: https://github.com/fubarhouse/dvm.git
  # dest is the namespace
  dest: github.com/fubarhouse/dvm
  # version refers to a tag, or branch.
  version: 2.2.5
  package: github.com/fubarhouse/dvm

To ensure all packages are removed before running the play, you can use the go_reget variable:

go_reget: true

To add/change the absolute path of shell profiles to configure, use golang_shell_profile.

If you do not define golang_shell_profile, the functionality will be ignored.

golang_shell_profile: /root/.bash_profile

To clean up an installation completely prior to role execution:

go_install_clean: true

To prevent clean up from removing GOPATH

go_install_clean_full: false

Setting permissions

Note: If you specify insufficient permissions the playbook will treat the following play as a new installation because it will not be able to determine what version is installed. To specify the permissions of the codebase, you can set:

mode_codebase: 0755

To specify the permissions of the workspace, you can set:

mode_workspace: 0755

Dependencies

None.

Example Playbook

- hosts: localhost
  roles:
    - fubarhouse.golang

Installation

  • Install using ansible-galaxy install fubarhouse.golang
  • Add this role to your playbook.
  • Modify above variables as desired.

License

MIT / BSD

Author Information

This role was created in 2016 by Karl Hepworth.

Image of Go's mascot was created by Takuya Ueda. Licenced under the Creative Commons 3.0 Attributions license. This image has been resized for purpose, but is otherwise unchanged.

ansible-role-golang's People

Contributors

celebdor avatar derekhiggins avatar dmitryromanov avatar fubarhouse avatar ioncebotari avatar isakrubin avatar liemle3893 avatar mpppk avatar phelipetls avatar saboteurkid avatar saleh199 avatar waquidvp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-role-golang's Issues

Allow for configurable GOROOT permissions.

A problem I feel is always getting in my way is folder permissions on GOROOT and/or the package paths under $GOPATH/bin, $GOPATH/src and $GOPATH/pkg.

We should have this as a configurable, with some sensible defaults...

GVM audit...

As I am a proper Gopher now, I am seeing less and less validity in a gvm release - other than building from source.

I want to explore this, and basically figure out if removing GVM support is a good idea. The added complexity and support isn't particularly of interest where the application gets very little use in comparison to traditional installation methods.

Build from source

In addition to issue #1 to install many versions, allow an option to build from source.

  • Populate GVM task file with source tasks
  • Test tasks on multiple platforms & work out problems
  • Quick once-over after everything is in place.

Cleanup tasks

After #1, #2, #3 and #4 are complete I'll look at a v1.0 release - I'll at least be happy then.

  • Add tasks file
  • Populate tasks file
  • Test tasks
  • Test logic
  • Implement changes on associated tasks files
  • General once-over upon completion

Update to working-copy

There were some changes I made in my local PyCharm IDE, obviously some time ago now.
Review and commit those changes, which affect the default installation settings among other changes.

Set system go to 1.4

For the sake of always having a compiler available for post 1.4 versions, we'll make 1.4 available always and set the system go to 1.4.

Restructure & Compatibility fixes

  • get travis tests to pass on all commons environments
  • restructure tasks for simplicity
  • audit everything, double check everything works, assess the functionality of the go get commands

Audit the exports

Basically just check over the following:

  • GOROOT declaration in shell exports
  • GOPATH declaration in shell exports
  • PATH=GOPATH declaration in shell exports
  • PATH=GOPATH/bin declaration in shell exports

GVM - Go Version Manager

I need to work out if this is going to be a thing I'll be implementing, and how this role would change to accommodate it.

It would be rather good if we could install them over the top of the file system and gvm just work automatically, but I need to look at the details.

  • Create task file
  • Populate task file with tasks
  • Test tasks on multiple platforms & work out problems
  • Identify why gvm use is failing
  • with symlinks now in place, do we really need to gvm use? refer to use script for answers.
  • Add tasks to build master
  • test tasks to build master
  • add configurable installation flags (useful because --binary --source and --prefer-binary are rather unreliable).
  • Configurable download mirror which replaces URL in GVM install script
  • provide master integration with go_versions to add master as well as multiple other
  • logic to prevent master installing where go{{ go_version }} should be installed
  • provide better support for <= v1.4 by attempting to completely remove the term 'go' from version strings. Thought: master/source already provides the functionality we need if the variable was to be passed through.
  • resolve the path issue with go get
  • Quick once-over after everything is in place.

Shell profiles could use rework.

Had a case today where the vagrant user .bash_profile which should have been touched, was actually the root user file, and the permissions were denied.

  • fix file path
  • test results.

Install < go1.4 from source

needs further work - I don't believe this should be done but it would be a nice feature, but it depends on the workload it'll introduce.

Add ability to manually install packages.

Post go-get, we should be able to clone any particular go repository (github or not) at a particular version of tag, and then install it manually.

  • Run go get tasks
  • Clone respective repository to place at version number x
  • Install via go

Install from source.

Installing Go1.4 via the recommended and setting the $GOROOT_BOOTSTRAP variable (which defaults to $HOME/go1.4/

These variables should be optional, as well as a flag to actually build go1.4 for bootstrapping.
Actual installation will happen via the recommended git release branch.

There should be additional logic for preventing traditional version numbers being used.
source installs are tied to specific versions, without the GOOS or GOARCH variables used in the file name (example: go1.8.1.src.tar.gz).

Building process is unified. ( ./all.bash ), and gcc should be installed for versions prior to 1.4 - but that will probably not be enforced in any way.

This issue supersedes issues #28 and #29.

Allow the ability to scrap packages prior to installation.

go_reget: true

Something which performs the function listed above will purge out the contents of:

  • $GOROOT/bin/bin
  • $GOROOT/bin/src
  • $GOROOT/bin/pkg

This will ensure a package is guaranteed to be re-fetched each time a play will run, which will get around an underlying problem I intend on investigating properly at a later date.

Remove commons dependency

There's no need for this dependency anymore, as it's only providing a couple of variables which in the case of this role are typically manually inputted. Two new tasks in setup.yml should cover it.

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.