diff --git a/.github/workflows/ce-provision-publish-docs.yml b/.github/workflows/ce-provision-publish-docs.yml index 2ba8cbc66..e3ef2ca95 100644 --- a/.github/workflows/ce-provision-publish-docs.yml +++ b/.github/workflows/ce-provision-publish-docs.yml @@ -1,60 +1,57 @@ -name: Build docs +name: Publish docs -# Run this workflow when a PR to 1.x gets merged +# Run this workflow on demand and every time a new commit pushed to your repository on: pull_request: - types: [closed] - branches: - - 1.x + workflow_dispatch: jobs: # Set the job key. The key is displayed as the job name # when a job name is not provided - build-docs: + public-docs: + if: ${{ github.event.pull_request.head.ref != 'documentation' }} # Name the Job - name: Build the documentation + name: Publish the ce-provision docs to GitHub # Set the type of machine to run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + + # Use our ce-dev Debian base container + container: + image: codeenigma/ce-dev-controller:2.x + volumes: + - ${{ github.workspace }}:/home/controller steps: - # Checks out a copy of your repository on the ubuntu-latest machine - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # Configures global Git variables for committing - - name: Configure Git + - name: Install wiki2pages + run: /usr/bin/su - ce-dev -c "/usr/bin/git clone https://github.com/codeenigma/wikis2pages.git /home/ce-dev/build/wiki2pages" + + - name: Set up Ansible hosts file + run: | + mkdir -p /home/ce-dev/ansible/bin/hosts + echo "wikis2pages-hugo ansible_host=127.0.0.1" > /home/ce-dev/ansible/bin/hosts/hosts + + - name: Set up SSH config run: | - git config --global user.email "sysadm@codeenigma.com" - git config --global user.name "Code Enigma CI" - git config --global pull.rebase false + echo "StrictHostKeyChecking=no" > /home/ce-dev/.ssh/config + cat /home/ce-dev/.ssh/id_rsa.pub > /home/ce-dev/.ssh/authorized_keys + chown ce-dev:ce-dev /home/ce-dev/.ssh/config + chmod 700 /home/ce-dev/.ssh/config + chown ce-dev:ce-dev /home/ce-dev/.ssh/authorized_keys + chmod 700 /home/ce-dev/.ssh/authorized_keys + + - name: Start SSHD + run: /usr/sbin/sshd& - # Installs the ce-dev stack - - name: Install ce-dev + - name: Initialise wiki2pages for ce-provision 2.x run: | - cd /tmp - wget https://golang.org/dl/go1.15.8.linux-amd64.tar.gz - sudo tar -C /usr/local -xzf go1.15.8.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - git clone https://github.com/FiloSottile/mkcert && cd mkcert - go build -ldflags "-X main.Version=$(git describe --tags)" - sudo mv ./mkcert /usr/local/bin && cd ../ - sudo chmod +x /usr/local/bin/mkcert - rm -Rf mkcert - curl -sL https://raw.githubusercontent.com/codeenigma/ce-dev/1.x/install.sh | /bin/sh -s -- linux - - # Uses the ce-dev stack to run Hugo to format and deploy the docs + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh init.sh --repo https://github.com/codeenigma/ce-provision.git --branch 2.x --no-ce-dev" + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /home/ce-dev/ansible/bin/ansible-playbook -e 'wiki2pages_build_path=/home/ce-dev/build/wiki2pages' -i /home/ce-dev/ansible/bin/hosts /home/ce-dev/build/wiki2pages/ce-dev/ansible/provision.yml" + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh set-current.sh --project ce-provision-2.x --no-ce-dev" + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /home/ce-dev/ansible/bin/ansible-playbook -e 'wiki2pages_build_path=/home/ce-dev/build/wiki2pages' -i /home/ce-dev/ansible/bin/hosts /home/ce-dev/build/wiki2pages/ce-dev/ansible/deploy.yml" + ls -la /home/ce-dev/build/wiki2pages/public/ce-provision-2.x/ + - name: Publish documentation run: | - cd - git clone https://github.com/codeenigma/wikis2pages.git - cd wikis2pages - /bin/bash init.sh https://${{ secrets.GITHUB_TOKEN }}@github.com/codeenigma/ce-provision.git 1.x - /bin/sh set-current.sh ce-provision-1.x - docker exec --user ce-dev --workdir /home/ce-dev/deploy/live.local wikis2pages-hugo hugo - /bin/sh .github-actions-push.sh - cd /home/runner/wikis2pages/public/ce-provision-1.x - git remote add ci https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/ce-provision-docs.git - git push ci master - shell: bash + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages && /bin/sh /home/ce-dev/build/wiki2pages/.github-actions-push.sh" + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages/public/ce-provision-2.x && /usr/bin/git remote add ci https://${{ secrets.DOCS_GITHUB_TOKEN }}@github.com/codeenigma/ce-provision-docs.git" + /usr/bin/su - ce-dev -c "cd /home/ce-dev/build/wiki2pages/public/ce-provision-2.x && /usr/bin/git push ci master" diff --git a/.github/workflows/ce-provision-test-nightly.yml b/.github/workflows/ce-provision-test-nightly.yml new file mode 100644 index 000000000..a10fdd67a --- /dev/null +++ b/.github/workflows/ce-provision-test-nightly.yml @@ -0,0 +1,43 @@ +name: Run night test builds + +# Run this workflow nightly +on: + schedule: + - cron: '30 4 * * *' + +jobs: + # Set the job key. The key is displayed as the job name + # when a job name is not provided + test-nightly: + # Name the Job + name: Build server with ce-provision + # Set the type of machine to run on + runs-on: ubuntu-latest + + # Use our ce-dev Debian base container + container: + image: codeenigma/ce-dev:2.x + volumes: + - ${{ github.workspace }}:/home/controller + + steps: + - name: Install ce-provision + run: | + /usr/bin/curl -LO https://raw.githubusercontent.com/codeenigma/ce-provision/2.x/install.sh + /usr/bin/chmod +x ./install.sh + /usr/bin/sudo ./install.sh --docker --no-firewall + + # Run a web server provision + - name: Prepare Git repos on disk + run: | + /usr/bin/git config --global --add safe.directory /home/controller/ce-provision + /usr/bin/git config --global --add safe.directory /home/controller/ce-provision/config + + - name: Start SSHD + run: /usr/sbin/sshd& + + - name: Provision a test web server + run: /usr/bin/su - controller -c "cd /home/controller/ce-provision && /bin/sh /home/controller/ce-provision/scripts/provision.sh --python-interpreter /home/controller/ce-python/bin/python3 --repo dummy --branch dummy --workspace /home/controller/ce-provision/ce-dev/ansible --playbook plays/web/ci.yml --own-branch 2.x --config-branch 2.x --force" + + - name: Provision a test GitLab server + run: /usr/bin/su - controller -c "cd /home/controller/ce-provision && /bin/sh /home/controller/ce-provision/scripts/provision.sh --python-interpreter /home/controller/ce-python/bin/python3 --repo dummy --branch dummy --workspace /home/controller/ce-provision/ce-dev/ansible --playbook plays/gitlab/ci.yml --own-branch 2.x --config-branch 2.x --force" diff --git a/.wikis2pages.yml b/.wikis2pages.yml index 7d33c03cb..f491e7fe0 100644 --- a/.wikis2pages.yml +++ b/.wikis2pages.yml @@ -1,10 +1,10 @@ -ce-provision-1.x: +ce-provision-2.x: src: https://github.com/codeenigma/ce-provision.git - src_branch: 1.x + src_branch: 2.x src_subdir: 'docs' dest: https://github.com/codeenigma/ce-provision-docs.git # remote and token for pushing added in GitHub Actions directly dest_branch: master - dest_subdir: 1.x + dest_subdir: 2.x title: ce-provision type: doc - base_url: https://codeenigma.github.io/ce-provision-docs/1.x + base_url: https://codeenigma.github.io/ce-provision-docs/2.x diff --git a/ce-dev/ce-dev.compose.yml b/ce-dev/ce-dev.compose.yml index f512e6176..c4a4e2188 100644 --- a/ce-dev/ce-dev.compose.yml +++ b/ce-dev/ce-dev.compose.yml @@ -1,4 +1,3 @@ -version: "3.7" x-ce_dev: version: 1.x registry: localhost:5000 diff --git a/install.sh b/install.sh index 7ca8822d0..53db4ce5d 100755 --- a/install.sh +++ b/install.sh @@ -14,7 +14,7 @@ usage(){ /usr/bin/echo '--version: ce-provision version to use (default: 2.x)' /usr/bin/echo '--user: Ansible controller user (default: controller)' /usr/bin/echo '--config: Git URL to your ce-provision Ansible config repository (default: https://github.com/codeenigma/ce-provision-config-example.git)' - /usr/bin/echo '--config-branch: branch of your Ansible config repository to use (default: 1.x)' + /usr/bin/echo '--config-branch: branch of your Ansible config repository to use (default: 2.x)' /usr/bin/echo '--no-firewall: skip installing iptables with ports 22, 80 and 443 open' /usr/bin/echo '--gitlab: install GitLab CE on this server (default: no, set to desired GitLab address to install, e.g. gitlab.example.com)' /usr/bin/echo '--letsencrypt: try to create an SSL certificate with LetsEncrypt (requires DNS pointing at this server for provided GitLab URL)' @@ -72,7 +72,7 @@ parse_options(){ VERSION="2.x" CONTROLLER_USER="controller" CONFIG_REPO="https://github.com/codeenigma/ce-provision-config-example.git" -CONFIG_REPO_BRANCH="1.x" +CONFIG_REPO_BRANCH="2.x" GITLAB_URL="no" LE_SUPPORT="no" FIREWALL="true" diff --git a/roles/debian/nodejs/defaults/main.yml b/roles/debian/nodejs/defaults/main.yml index 7e2324abf..0ae6c011c 100644 --- a/roles/debian/nodejs/defaults/main.yml +++ b/roles/debian/nodejs/defaults/main.yml @@ -1,7 +1,7 @@ --- nodejs: # Used by apt_unattended_upgrades - apt_origin_nodejs: "origin=. nodistro,codename=nodistro,label=. nodistro" # nodejs repo + apt_origin_nodejs: "origin=Node Source,codename=nodistro,label=Node Source" # nodejs repo apt_signed_by_nodejs: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key apt_origin_yarn: "origin=yarn,codename=stable,label=yarn-stable" # yarn repo apt_signed_by_yarn: https://dl.yarnpkg.com/debian/pubkey.gpg diff --git a/roles/debian/nodejs/tasks/main.yml b/roles/debian/nodejs/tasks/main.yml index 3128b7bb8..0806e47f5 100644 --- a/roles/debian/nodejs/tasks/main.yml +++ b/roles/debian/nodejs/tasks/main.yml @@ -19,6 +19,14 @@ enabled: true key_refresh_timer_OnCalendar: "Mon *-*-* 00:15:00" +- name: Modify repository for Node.js 10.x + set_fact: + apt_repository: + types: "deb deb-src" + suites: "{{ ansible_distribution_release }}" + signed_by: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key" + when: nodejs.version == "10.x" + - name: Add Yarn repository and key. ansible.builtin.include_role: name: debian/apt_repository diff --git a/roles/debian/ssl/templates/le_cron.sh.j2 b/roles/debian/ssl/templates/le_cron.sh.j2 index d4af6bffb..dc7219155 100644 --- a/roles/debian/ssl/templates/le_cron.sh.j2 +++ b/roles/debian/ssl/templates/le_cron.sh.j2 @@ -37,7 +37,8 @@ if [ $certbot_exit_code -ne 0 ]; then # Certbot failed, send email notification recipient="{{ ssl.email }}" subject="Certbot Renewal Failed" - body="Certbot renewal failed with the following output: + hostname=$(cat /etc/hostname) + body="Certbot renewal failed on server $hostname with the following output: $certbot_output" send_email_notification "$recipient" "$subject" "$body"