From f4e0e3324566676e165d53d0d03c1ccc0584fbf7 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Fri, 5 Jul 2024 15:23:05 +0200 Subject: [PATCH] refactor(infra): increase ssh connection persistence to 1h --- .github/workflows/infrastructure.yml | 13 ++++++++++--- infrastructure/nomad/ansible.cfg.example | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infrastructure.yml b/.github/workflows/infrastructure.yml index be07b2a6e..f93ce766d 100644 --- a/.github/workflows/infrastructure.yml +++ b/.github/workflows/infrastructure.yml @@ -131,6 +131,15 @@ jobs: - name: Configure Control Machine run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + cat <> ~/.ssh/config + Host * + ControlMaster auto + ControlPath /tmp/ssh_mux_%h_%p_%r + ControlPersist 10m + EOF + ANSIBLE_USER="${USER}" ANSIBLE_CONNECTION="ansible_connection=local" if [ "${IS_MANUAL_DEPLOYMENT}" == "true" ]; then @@ -138,9 +147,7 @@ jobs: ANSIBLE_CONNECTION="" export ANSIBLE_HOST_KEY_CHECKING=false - mkdir -p ~/.ssh && \ - chmod 700 ~/.ssh && \ - echo "${{ secrets.INFRASTRUCTURE_DEPLOYMENT_KEY }}" > ~/.ssh/id_ed25519 && \ + echo "${{ secrets.INFRASTRUCTURE_DEPLOYMENT_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 fi diff --git a/infrastructure/nomad/ansible.cfg.example b/infrastructure/nomad/ansible.cfg.example index 148df3252..ca3b403da 100644 --- a/infrastructure/nomad/ansible.cfg.example +++ b/infrastructure/nomad/ansible.cfg.example @@ -8,7 +8,6 @@ timeout = 10 connection = ssh pipelining = True host_key_checking = False -ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes fact_caching = jsonfile fact_caching_connection = /tmp/ansible_facts_cache fact_caching_timeout = 86400 @@ -17,3 +16,6 @@ module_defaults: gather_subset: - '!all' - 'min' + +[ssh_connection] +ssh_args = -o ControlMaster=auto -o ControlPersist=60m -o ControlPath=/tmp/ssh_mux_%h_%p_%r -o ForwardAgent=yes