diff --git a/day1_geninventory.sh b/day1_geninventory.sh index 1e054ef..b7a44e5 100755 --- a/day1_geninventory.sh +++ b/day1_geninventory.sh @@ -23,6 +23,10 @@ EOF cat > ansible.cfg << EOF [defaults] inventory = $(pwd)/hosts + +[ssh_connection] +ssh_args = "-o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey" +pipelining = true EOF ansible "$CATEGORY" -m ping diff --git a/day3_geninventory_phase1.sh b/day3_geninventory_phase1.sh index e65b7a9..ae5c3b6 100755 --- a/day3_geninventory_phase1.sh +++ b/day3_geninventory_phase1.sh @@ -34,6 +34,10 @@ EOF cat > ansible.cfg << EOF [defaults] inventory = $(pwd)/hosts + +[ssh_connection] +ssh_args = "-o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey" +pipelining = true EOF ansible "$CATEGORY" -m ping diff --git a/day3_geninventory_phase2.sh b/day3_geninventory_phase2.sh index f83820f..2f83e61 100755 --- a/day3_geninventory_phase2.sh +++ b/day3_geninventory_phase2.sh @@ -39,6 +39,10 @@ EOF cat > ansible.cfg << EOF [defaults] inventory = $(pwd)/hosts + +[ssh_connection] +ssh_args = "-o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey" +pipelining = true EOF ansible "$CATEGORY" -m ping diff --git a/jupyterhubsrv.yml b/jupyterhubsrv.yml index 1f99154..3e64374 100644 --- a/jupyterhubsrv.yml +++ b/jupyterhubsrv.yml @@ -1,6 +1,7 @@ --- - name: Install Jupyterhub hosts: UpskillChallengeNode + gather_facts: no tasks: - name: Create NodeJS directory @@ -23,7 +24,7 @@ mode: 0755 - name: run NodeJS configuration script - ansible.builtin.shell: setup_14.x + ansible.builtin.shell: /opt/nodesource/setup_14.x args: chdir: /opt/nodesource creates: /etc/apt/sources.list.d/nodesource.list diff --git a/omniconfig.sh b/omniconfig.sh new file mode 100755 index 0000000..16e290c --- /dev/null +++ b/omniconfig.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +d () +{ + date '+%F %T' +} + +echo $(d): Starting server +ROOT_PASS="Swordfish4321!" ./day0_create.sh +./wait_ready.sh +./day1_geninventory.sh +echo $(d): Creating user account +ansible-playbook phase1user.yml > .phase1.log +./day3_geninventory_phase1.sh +echo $(d): Securing SSH access +ansible-playbook phase2user.yml > .phase2.log +./day3_geninventory_phase2.sh +echo $(d): configuring jupyterhub +ansible-playbook jupyterhubsrv.yml > .jupyterhub.log +echo $(d): ready + diff --git a/phase1user.yml b/phase1user.yml index 9068922..e97f597 100644 --- a/phase1user.yml +++ b/phase1user.yml @@ -1,6 +1,7 @@ --- - name: Create admin user hosts: UpskillChallengeNode + gather_facts: no vars: newusername: "tachyon" diff --git a/phase2user.yml b/phase2user.yml index 27df0b8..a2e90a6 100644 --- a/phase2user.yml +++ b/phase2user.yml @@ -1,6 +1,7 @@ --- - name: Lock down root & SSH on the server hosts: UpskillChallengeNode + gather_facts: no tasks: - name: Disable root login over ssh diff --git a/wait_ready.sh b/wait_ready.sh new file mode 100755 index 0000000..3d497fe --- /dev/null +++ b/wait_ready.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ -z ""] +then + LABEL="UpskillChallengeNode" +fi + +NODESTATE="indeterminate" +while [ "$NODESTATE" != "running" ] +do + OLDSTATE=$NODESTATE + NODESTATE=$(linode-cli linodes list --format 'status' --label "$LABEL" --text | tail -n 1) + if [ "$NODESTATE" = "status" ] + then + echo "No node detected." + exit 1 + fi + + if [ "$NODESTATE" != "$OLDSTATE" ] + then + echo "$(date '+%F %T'): $NODESTATE" + fi +done