Skip to content

Commit

Permalink
Merge pull request #39 from stackhpc/feature/etc-hosts
Browse files Browse the repository at this point in the history
Adds etc-hosts element
  • Loading branch information
Alex-Welsh authored Feb 16, 2023
2 parents a6b7b34 + 1522b7d commit 13a944e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions elements/etc-hosts/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=========
etc-hosts
=========
Appends text to /etc/hosts.

`DIB_ETC_HOSTS_EXTRA`: Lines to add to /etc/hosts

For example:

.. code-block::
export DIB_ETC_HOSTS_EXTRA="192.168.20.1 compute-host-01"
Or:

export DIB_ETC_HOSTS_EXTRA=`cat ./my-hosts`
3 changes: 3 additions & 0 deletions elements/etc-hosts/environment.d/etc-hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

export ETC_HOSTS_EXTRA=${DIB_ETC_HOSTS_EXTRA:?"You must define DIB_ETC_HOSTS_EXTRA"}
9 changes: 9 additions & 0 deletions elements/etc-hosts/pre-install.d/01-etc-hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail

printf "$ETC_HOSTS_EXTRA" >> /etc/hosts

0 comments on commit 13a944e

Please sign in to comment.