github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/README.md (about) 1 juju 2 ==== 3 4 juju is devops distilled. 5 6 Juju enables you to use [Charms](https://docs.jujucharms.com/stable/en/charms) to deploy your 7 application architectures to EC2, OpenStack, Azure, GCE, your data center, and 8 even your own Ubuntu based laptop. Moving between models is simple giving you 9 the flexibility to switch hosts whenever you want — for free. 10 11 For more information, see the [docs](https://docs.jujucharms.com/stable/en/getting-started). 12 13 Getting started 14 =============== 15 16 `juju` is written in Go (http://golang.org), a modern, compiled, statically typed, 17 concurrent language. This document describes how to build `juju` from source. 18 19 If you are looking for binary releases of `juju`, they are available in the snap store 20 21 snap install juju --classic 22 23 Installing Go 24 -------------- 25 26 `Juju's` source code currently depends on Go 1.11. One of the easiest ways 27 to install golang is from a snap. You may need to first install 28 the [snap client](https://snapcraft.io/docs/core/install). Installing the golang 29 snap package is then as easy as 30 31 snap install go --channel=1.11/stable --classic 32 33 You can read about the "classic" confinement policy [here](https://insights.ubuntu.com/2017/01/09/how-to-snap-introducing-classic-confinement/) 34 35 If you want to use `apt`, then you can add the [Golang Gophers PPA](https://launchpad.net/~gophers/+archive/ubuntu/archive) and then install by running the following 36 37 sudo add-apt-repository ppa:gophers/archive 38 sudo apt-get update 39 sudo apt install golang-1.11 40 41 Alternatively, you can always follow the official [binary installation instructions](https://golang.org/doc/install#install) 42 43 Setting GOPATH 44 -------------- 45 46 When working with the source of Go programs, you should define a path within 47 your home directory (or other workspace) which will be your `GOPATH`. `GOPATH` 48 is similar to Java's `CLASSPATH` or Python's `~/.local`. `GOPATH` is documented 49 online at `http://golang.org/pkg/go/build/` and inside the `go` tool itself 50 51 go help gopath 52 53 Various conventions exist for naming the location of your `GOPATH`, but it should 54 exist, and be writable by you. For example 55 56 export GOPATH=${HOME}/work 57 mkdir $GOPATH 58 59 will define and create `$HOME/work` as your local `GOPATH`. The `go` tool itself 60 will create three subdirectories inside your `GOPATH` when required; `src`, `pkg` 61 and `bin`, which hold the source of Go programs, compiled packages and compiled 62 binaries, respectively. 63 64 Setting `GOPATH` correctly is critical when developing Go programs. Set and 65 export it as part of your login script. 66 67 Add `$GOPATH/bin` to your `PATH`, so you can run the go programs you install: 68 69 PATH="$GOPATH/bin:$PATH" 70 71 72 Getting juju 73 ============ 74 75 The easiest way to get the source for `juju` is to use the `go get` command. 76 77 go get -d -v github.com/juju/juju/... 78 79 This command will checkout the source of `juju` and inspect it for any unmet 80 Go package dependencies, downloading those as well. `go get` will also build and 81 install `juju` and its dependencies. To checkout without installing, use the 82 `-d` flag. More details on the `go get` flags are available using 83 84 go help get 85 86 At this point you will have the git local repository of the `juju` source at 87 `$GOPATH/src/github.com/juju/juju`. The source for any dependent packages will 88 also be available inside `$GOPATH`. You can use `git pull --rebase`, or the 89 less convenient `go get -u github.com/juju/juju/...` to update the source 90 from time to time. 91 If you want to know more about contributing to `juju`, please read the 92 [CONTRIBUTING](CONTRIBUTING.md) companion to this file. 93 94 Installing prerequisites 95 ------------------------ 96 97 ### *Making use of Makefile* 98 99 The `juju` repository contains a `Makefile`, which is the preferred way to 100 install dependencies and other features. It is advisable, when installing 101 `juju` from source, to look at the [Makefile](./Makefile), located in 102 `$GOPATH/src/github.com/juju/juju/Makefile`. 103 104 ### *Dependencies* 105 106 Juju needs some dependencies in order to be installed and the preferred way to 107 collect the necessary packages is to use the provided `Makefile`. 108 The target `dep` will download the go packages listed in `Gopkg.lock`. 109 The following bash code will install the dependencies. 110 111 cd $GOPATH/src/github.com/juju/juju 112 export JUJU_MAKE_GODEPS=true 113 make dep 114 115 ### *Runtime Dependencies* 116 117 You can use `make install-dependencies` or, if you prefer to install 118 them manually, check the Makefile target. 119 120 This will add some PPAs to ensure that you can install the required 121 golang and mongodb-server versions for precise onwards, in addition to the 122 other dependencies. 123 124 ### *Build Dependencies* 125 126 Before you can build Juju, see 127 [Dependency management](CONTRIBUTING.md#dependency-management) section of 128 `CONTRIBUTING` to ensure you have build dependencies setup. 129 130 131 Building juju 132 ============= 133 134 go install -v github.com/juju/juju/... 135 136 Will build juju and install the binary commands into `$GOPATH/bin`. It is likely 137 if you have just completed the previous step to get the `juju` source, the 138 install process will produce no output, as the final executables are up-to-date. 139 140 If you do see any errors, there is a good chance they are due to changes in 141 juju's dependencies. See the 142 [Dependency management](CONTRIBUTING.md#dependency-management) section of 143 `CONTRIBUTING` for more information on getting the dependencies right. 144 145 146 Using juju 147 ========== 148 149 After following the steps above you will have the `juju` client installed in 150 `GOPATH/bin/juju`. You should ensure that this version of `juju` appears earlier 151 in your path than any packaged versions of `juju`, or older Python juju 152 commands. You can verify this using 153 154 which juju 155 156 You should be able to bootstrap a local model now with the following: 157 158 juju bootstrap localhost 159 160 Installing bash completion for juju 161 =================================== 162 163 make install-etc 164 165 Will install Bash completion for `juju` cli to `/usr/share/bash-completion/completions/juju`. It does 166 dynamic completion for commands requiring service, unit or machine names (like e.g. 167 juju status <service>, juju ssh <instance>, juju terminate-machine <machine#>, etc), 168 by parsing cached `juju status` output for speedup. It also does command flags 169 completion by parsing `juju help ...` output. 170 171 If you are using zsh instead of bash you can follow the steps above and add the 172 following lines to the end of your `.zshrc` file: 173 174 ```bash 175 autoload -U +X compinit && compinit 176 autoload -U +X bashcompinit && bashcompinit 177 [ -f /usr/share/bash-completion/completions/juju ] && source /usr/share/bash-completion/completions/juju 178 ``` 179 180 Building Juju as a Snap Package 181 =============================== 182 183 Building 184 -------- 185 Make sure your snapcraft version is >= 2.26. Run `snapcraft` at the root of the repository. A snap will build. 186 187 Building with Local Changes 188 -------- 189 190 Note that the default snapcraft.yaml file does a git clone of a local repository so if you need to include 191 any local changes, they have to be committed first as git ignores uncommitted changes during a local clone. 192 193 In some cases patches for dependencies are applied locally by invoking `patch` with snap scriptlets (see snapcraft.yaml). 194 This may cause successive rebuilds after `snapcraft clean -s build` to fail as patches will be applied 195 on an already patched code-base. In order to avoid that just clear all stages via `snapcraft clean`. 196 197 Current State 198 ------------- 199 Classic mode. 200 201 Known Issues 202 ------------ 203 None. The snap shares your current credentials and environments as expected with a debian installed version. 204 205 Needed for confinement 206 ---------------------- 207 To enable strict mode, the following bugs need to be resolved, and the snap updated accordingly. 208 209 * Missing support for abstract unix sockets (https://bugs.launchpad.net/snappy/+bug/1604967) 210 * Juju plugin support (https://bugs.launchpad.net/juju/+bug/1628538) 211 212