Jenkins: node, stage, step

node

node allocates an executor on a Jenkins node (aka a slave) and runs code in the context of the workspace on that node.

https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node

Another wrinkle on node‘s. There is also the concept of flyweight and heavyweight executors. A flyweight executor is just a thread and runs inside the Java master’s JVM. A heavyweight executor is a process (e.g. `sh` ) and will halt the flow on the master so should be allocated to a node. From the docs:

It is recommended to allocate executors to agent machines, rather than on the Jenkins master – to avoid potential security vulnerabilities, Out-Of-Memory and other performance issues. To do this, configure the “# of executors” to ‘0’ on the “master” node (by default this setting is ‘2’).

https://support.cloudbees.com/hc/en-us/articles/216456477-What-is-a-Jenkins-Executor-and-how-can-I-best-utilize-my-executors

See also https://support.cloudbees.com/hc/en-us/articles/360012808951-Pipeline-Difference-between-flyweight-and-heavyweight-Executors

stage

`stage` creates a labelled block and show up as columns in the Pipeline Stage view.

https://jenkins.io/doc/pipeline/steps/pipeline-stage-step/

See also Jenkins: milestone plugin and this post on Stage vs Lock vs Milestone.

step

A step is a single action. When a step succeeds it moves onto the next step. When a step fails to execute correctly the Pipeline will fail.

https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#step-general-build-step

See also

https://stackoverflow.com/questions/39549215/what-is-the-difference-between-a-node-stage-and-step-in-jenkins-pipelines

 

Note also the keyword steps

https://jenkins.io/doc/pipeline/tour/running-multiple-steps/

 

Docker: Apache container with sidecar

Why would you use a sidecar?

e.g. to add something to an existing container without rewriting it.

Assuming you’ve run a container with Apache as in this post: Docker: Apache container then you’ll have an environment variable, `APP_ID`.

You can use this to run a sidecar container that adds a health metric. E.g.

docker run --pid=container:${APP_ID} -p 8081:8081 brendanburns/topz:db0fa58 /server --addr=0.0.0.0:8081

and now you have a sidecar container running. E.g.

`curl localhost:8081`

“`

91 9.937410610507195 0.02218294 /server –addr=0.0.0.0:8081
1 0 0.0024320167 httpd -DFOREGROUND
7 0 0.005011428 httpd -DFOREGROUND
8 0 0.0008106722 httpd -DFOREGROUND
9 0 0.0009335013 httpd -DFOREGROUND

“`

 

 

Docker: Apache container

Running Apache in Docker from Ubuntu

Install Docker

curl -fsSL https://get.docker.com | sh

 

To allow you to use Docker as a user

sudo usermod -aG docker <username>

 

Run Docker with Apache image:

sudo docker run -dit –name apache -p 8080:80 -v /tmp/webroot:/usr/local/apache2/htdocs/ httpd:2.4

This will overwrite anything you’ve written to `local webroot path`.

Also, `8080:80` is `host:container`.

See also docker container run

 

And `docker stop <your container name>` will not delete that volume. It persists.

https://docs.docker.com/storage/

 

Test from local machine with:

curl localhost:8080

 

Note: you can access your container ID if you know the container name. E.g. assuming the container name is apache then you can use:

`APP_ID=docker ps | grep apache | awk ‘{print $1}’`

 

Jenkins CLI

Jenkins has a built-in command line interface that allows you to access Jenkins from a script or from your shell. This is convenient for automation of routine tasks, bulk updates, trouble diagnosis, and so on.

This interface is accessed via the Jenkins CLI client, which is a Java JAR file distributed with Jenkins.

You can download the JAR file for the client from the URL “/jnlpJars/jenkins-cli.jar” on your Jenkins server, e.g. https://jenkins.example.com/jnlpJars/jenkins-cli.jar

E.g. for `help`, use:

java -jar /var/lib/jenkins/cli/jenkins-cli.jar -auth <jenkins username>:<jenkins password> -s http://localhost:8080 help

Other options (instead of help):

  • safe_restart
  • version

https://wiki.jenkins.io/display/JENKINS/Jenkins+CLI

Ansible: ansible.cfg – adding roles to your path, tuning OpenSSH

A few config settings to tune Ansible:

`roles_path` let’s you add another directory for roles.

https://docs.ansible.com/ansible/2.4/intro_configuration.html#roles-path

 

ssh_connection lets you tune the OpenSSH connection. E.g. ControlPersist (note – only modern OS’s – i.e. > RHEL6).

https://docs.ansible.com/ansible/2.4/intro_configuration.html#openssh-specific-settings

which can improve Performance settings.

https://dzone.com/articles/speed-up-ansible

but beware some potential pitfalls – use unique ControlPath settings – e.g.

control_path = %(directory)s/%%h-%%r

https://docs.ansible.com/ansible/2.4/intro_configuration.html#control-path

Ubuntu 16.04 LTS – debugging Wifi connections

Unbelievable.

Ubuntu 16.04 LTS could not connect to my Wifi network on either of 2 separate Dell laptops (the newer laptops have terrible keyboard layouts by the way. The one I’m using has shoe-horned a number pad to the right of the main keyboard. So there are 2 enter buttons. The Enter button on the right of the normal keyboard is tiny! There are also 2 sets of mouse buttons – one for the IBM style middle of the keyboard nipple and one for the trackpad. Crazy frankenstein monster.)

 

My Mac was fine connecting to the network.

Another wasted evening weekend due to Linux’s crappy Wifi networking.

 

ifconfig does not show gateway info.

Instead you need to do:

ip route | grep default

 

Here’s an example of the sort of advice people are getting to try and fix it:

Please do:
Code:
sudo apt-get purge bcmwl-kernel-source
Wifi should work again.
Then:
Code:
echo "options rt2800pci nohwcrypt=y" | sudo tee /etc/modprobe.d/rt2800pci.conf
sudo modprobe -rfv rt2800pci
sudo modprobe -v rt2800pci
Set your network manager settings to match the screenshots and the disconnects should stop and probably have a faster connection.

What a shit-show!

 

Dell’s advice?

https://www.dell.com/support/article/uk/en/ukbsdt1/sln151759/how-to-troubleshoot-wireless-network-issues-in-ubuntu-linux-on-your-dell-pc?lang=en

Use `nm-tool` – a tool now deprecated and no longer supplied with Ubuntu.

 

These:

`nmcli c` (more on this later)

lshw -c network

are the replacements.

Also useful:

`iwconfig`

 

nmcli

is awesome. E.g.

nmcli device wifi list

will show you the Bars, Signal strength and Security.

And put an asterisk next to the connection you’re connected to.

 

nmcli networking connectivity

is not much use. It shows: `full` even if you can’t connect to the internet.

 

`nmcli monitor`

shows connection progress.

However it reports `connected` even if you can’t connect to the internet.

 

 

 

 

Install virtualbox on Ubuntu with UEFI Secure boot

https://askubuntu.com/a/768310

 

 

 ┌────────────────────────────────────────────────────────────┤ Configuring Secure Boot ├────────────────────────────────────────────────────────────┐  
 │                                                                                                                                                   │  
 │ Your system has UEFI Secure Boot enabled.                                                                                                         │  
 │                                                                                                                                                   │  
 │ UEFI Secure Boot is not compatible with the use of third-party drivers.                                                                           │  
 │                                                                                                                                                   │  
 │ The system will assist you in toggling UEFI Secure Boot. To ensure that this change is being made by you as an authorized user, and not by an     │  
 │ attacker, you must choose a password now and then use the same password after reboot to confirm the change.                                       │  
 │                                                                                                                                                   │  
 │ If you choose to proceed but do not confirm the password upon reboot, Ubuntu will still be able to boot on your system but the Secure Boot state  │  
 │ will not be changed.                                                                                                                              │  
 │                                                                                                                                                   │  
 │ If Secure Boot remains enabled on your system, your system may still boot but any hardware that requires third-party drivers to work correctly    │  
 │ may not be usable.                                                                                                                                │  
 │

e.g.

 

Setting up virtualbox (5.1.38-dfsg-0ubuntu1.16.04.2) …
vboxweb.service is a disabled or a static unit, not starting it.
Job for virtualbox.service failed because the control process exited with error code. See “systemctl status virtualbox.service” and “journalctl -xe” for details.
invoke-rc.d: initscript virtualbox, action “restart” failed.
● virtualbox.service – LSB: VirtualBox Linux kernel module
Loaded: loaded (/etc/init.d/virtualbox; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-01-29 15:51:32 GMT; 2ms ago
Docs: man:systemd-sysv-generator(8)
Process: 10816 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)

Jan 29 15:51:32 w-dell systemd[1]: Starting LSB: VirtualBox Linux kernel module…
Jan 29 15:51:32 w-dell virtualbox[10816]: * Loading VirtualBox kernel modules…
Jan 29 15:51:32 w-dell virtualbox[10816]: * modprobe vboxdrv failed. Please use ‘dmesg’ to find out why
Jan 29 15:51:32 w-dell virtualbox[10816]: …fail!
Jan 29 15:51:32 w-dell systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Jan 29 15:51:32 w-dell systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
Jan 29 15:51:32 w-dell systemd[1]: virtualbox.service: Unit entered failed state.
Jan 29 15:51:32 w-dell systemd[1]: virtualbox.service: Failed with result ‘exit-code’.
Setting up virtualbox-qt (5.1.38-dfsg-0ubuntu1.16.04.2) …
Processing triggers for libc-bin (2.23-0ubuntu10) …
Processing triggers for shim-signed (1.33.1~16.04.3+15+1533136590.3beb971-0ubuntu1) …
Processing triggers for systemd (229-4ubuntu21.15) …
Processing triggers for ureadahead (0.100.0-19) …
W: Operation was interrupted before it could finish