Files
weave-scope/config_management
Bryan Boreham 7f4bab626e Squashed 'tools/' changes from 74dc626b..2bbc9a08
2bbc9a08 Merge pull request #140 from weaveworks/sched-http-retry
c3726dea Add retries to sched util http calls
2cc7b5ac Merge pull request #139 from meghalidhoble/master
fd9b0a72 Change : Modified the lint tools to skip the shfmt check if not installed. Why the change : For ppc64le the specific version of shfmt is not available, hence skipped completely the installation of shfmt tool. Thus this change made.
bc645c70 Merge pull request #138 from dholbach/add-license-file
a642e022 license: add Apache 2.0 license text
9bf59568 Merge pull request #109 from hallum/master
d971d821 Merge pull request #134 from weaveworks/2018-07-03-gcloud-regepx
32e7aa2d Merge pull request #137 from weaveworks/gcp-fw-allow-kube-apiserver
bbb6735e Allow CI to access k8s API server on GCP instances
764d46ca Merge pull request #135 from weaveworks/2018-07-04-docker-ansible-playbook
ecc2a4e3 Merge pull request #136 from weaveworks/2018-07-05-gcp-private-ips
209b7fb6 tools: Add private_ips to the terraform output
369a655f tools: Add an ansible playbook that just installs docker
a643e270 tools: Use --filter instead of --regexp with gcloud
b8eca887 Merge pull request #128 from weaveworks/actually-say-whats-wrong
379ce2bb Merge pull request #133 from weaveworks/fix-decrypt
3b906b54 Fix incompatibility with recent versions of OpenSSL
f091ab43 Merge pull request #132 from weaveworks/add-opencontainers-labels-to-dockerfiles
248def1b Inject git revision in Dockerfiles
64f2c280 Add org.opencontainers.image.* labels to Dockerfiles
ea96d8ed add information about how to get help (#129)
f066ccdd Make yapf diff failure look like an error
34d81d70 Merge pull request #127 from weaveworks/golang-1.10.0-stretch
89a0b4f8 Use golang:1.10.0-stretch image.
ca69607f Merge pull request #126 from weaveworks/disable-apt-daily-test
f5dc5d54 Create "setup-apt" role
7fab4413 Rename bazel to bazel-rules (#125)
ccc83168 Revert "Gocyclo should return error code if issues detected" (#124)
1fe184f1 Bazel rules for building gogo protobufs (#123)
b917bb89 Merge pull request #122 from weaveworks/fix-scope-gc
c029ce01 Add regex to match scope VMs
0d4824b1 Merge pull request #121 from weaveworks/provisioning-readme-terraform
5a82d64c Move terraform instructions to tf section
d285d78d Merge pull request #120 from weaveworks/gocyclo-return-value
76b94a47 Do not spawn subshell when reading cyclo output
93b3c0d5 Use golang:1.9.2-stretch image
d40728f6 Gocyclo should return error code if issues detected
c4ac1c3f Merge pull request #114 from weaveworks/tune-spell-check
89806560 Only check files
12ebc73a Don't spell-check pki files
578904ab Special-case spell-check the same way we do code checks
e772ed59 Special-case on mime type and extension using just patterns
ae82b50c Merge pull request #117 from weaveworks/test-verbose
89434738 Propagate verbose flag to 'go test'.
7c79b43c Merge pull request #113 from weaveworks/update-shfmt-instructions
258ef015 Merge pull request #115 from weaveworks/extra-linting
e690202b Use tools in built image to lint itself
126eb561 Add shellcheck to bring linting in line with scope
63ad68f0 Don't run lint on files under .git
51d908a3 Update shfmt instructions
e91cb0d3 Merge pull request #112 from weaveworks/add-python-lint-tools
0c87554d Add yapf and flake8 to golang build image
35679ee5 Merge pull request #110 from weaveworks/parallel-push-errors
3ae41b6f Remove unneeded if block
51ff31a5 Exit on first error
0faad9f7 Check for errors when pushing images in parallel
d87cd026 Add arg flag override for destination socks host:port in pacfile.

git-subtree-dir: tools
git-subtree-split: 2bbc9a08a7f672eae62cfe110d7f536c6cc53ce3
2018-08-10 12:31:52 +00:00
..

Weaveworks configuration management

Introduction

This project allows you to configure a machine with:

  • Docker and Weave Net for development: setup_weave-net_dev.yml
  • Docker and Weave Net for testing: setup_weave-net_test.yml
  • Docker, Kubernetes and Weave Kube (CNI plugin): setup_weave-kube.yml

You can then use these environments for development, testing and debugging.

Set up

You will need Python and Ansible 2.+ installed on your machine and added to your PATH in order to be able to configure environments automatically.

  • On any platform, if you have Python installed: pip install ansible
  • On macOS: brew install ansible
  • On Linux (via Aptitude): sudo apt install ansible
  • On Linux (via YUM): sudo yum install ansible
  • For other platforms or more details, see here

Frequent errors during installation are:

  • fatal error: Python.h: No such file or directory: install python-dev
  • fatal error: ffi.h: No such file or directory: install libffi-dev
  • fatal error: openssl/opensslv.h: No such file or directory: install libssl-dev

Full steps for a blank Ubuntu/Debian Linux machine:

sudo apt-get install -qq -y python-pip python-dev libffi-dev libssl-dev
sudo pip install -U cffi
sudo pip install ansible

Tags

These can be used to selectively run (--tags "tag1,tag2") or skip (--skip-tags "tag1,tag2") tasks.

  • output: print potentially useful output from hosts (e.g. output of kubectl get pods --all-namespaces)

Usage

Local machine

ansible-playbook -u <username> -i "localhost", -c local setup_weave-kube.yml

Vagrant

Provision your local VM using Vagrant:

cd $(mktemp -d -t XXX)
vagrant init ubuntu/xenial64  # or, e.g. centos/7
vagrant up

then set the following environment variables by extracting the output of vagrant ssh-config:

eval $(vagrant ssh-config | sed \
-ne 's/\ *HostName /vagrant_ssh_host=/p' \
-ne 's/\ *User /vagrant_ssh_user=/p' \
-ne 's/\ *Port /vagrant_ssh_port=/p' \
-ne 's/\ *IdentityFile /vagrant_ssh_id_file=/p')

and finally run:

ansible-playbook --private-key=$vagrant_ssh_id_file -u $vagrant_ssh_user \
--ssh-extra-args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
-i "$vagrant_ssh_host:$vagrant_ssh_port," setup_weave-kube.yml

or, for specific versions of Kubernetes and Docker:

ansible-playbook --private-key=$vagrant_ssh_id_file -u $vagrant_ssh_user \
--ssh-extra-args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
-i "$vagrant_ssh_host:$vagrant_ssh_port," setup_weave-kube.yml \
--extra-vars "docker_version=1.12.3 kubernetes_version=1.4.4"

NOTE: Kubernetes APT repo includes only the latest version, so currently retrieving an older version will fail.

Terraform

Provision your machine using the Terraform scripts from ../provisioning, then run:

terraform output ansible_inventory > /tmp/ansible_inventory

and

ansible-playbook \
    --private-key="$(terraform output private_key_path)" \
    -u "$(terraform output username)" \
    -i /tmp/ansible_inventory \
    --ssh-extra-args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
    ../../config_management/setup_weave-kube.yml

To specify versions of Kubernetes and Docker see Vagrant examples above.

N.B.: --ssh-extra-args is used to provide:

  • StrictHostKeyChecking=no: as VMs come and go, the same IP can be used by a different machine, so checking the host's SSH key may fail. Note that this introduces a risk of a man-in-the-middle attack.
  • UserKnownHostsFile=/dev/null: if you previously connected a VM with the same IP but a different public key, and added it to ~/.ssh/known_hosts, SSH may still fail to connect, hence we use /dev/null instead of ~/.ssh/known_hosts.

Docker installation role

Various ways to install Docker are provided:

  • docker-from-docker-ce-repo
  • docker-from-docker-repo
  • docker-from-get.docker.com
  • docker-from-tarball

each producing a slightly different outcome, which can be useful for testing various setup scenarios.

The docker-install role selects one of the above ways to install Docker based on the docker_install_role variable. The default value for this variable is configured in group_vars/all. You can however override it with whichever role you would want to run by passing the name of the role as a key-value pair in extra-vars, e.g.:

ansible-playbook <playbook>.yml \
    --extra-vars "docker_install_role=docker-from-docker-ce-repo"

Resources