Skip to content

Commit e0888ff

Browse files
authored
Bug fixes 2.x pr 2.x (#2280)
* Updating CI to 2.x. * Defending against missing Ansible. * Making the ce-provision-config branch in CI dynamic. * We do not want a 'ce-dev provision' because it breaks our controller. * Reverting 'ce-dev provision' change. * Trying a different ansible_facts var. * Testing using the source branch in ce-dev. * Setting max_childen to an integer to avoid CI issues. * Trying to change the python interpreter used. * Adding platform and cgroup values to ce-dev compose template. * Trying latest ubuntu containers in GitHub Actions. * Fixing the test.sh script to work with venvs. * Documentation for PHP in CI. * Adding GitLab test back in. * Fixing role namespaces. * Minor bug fixes to ce-provision installer. * Testing installing ce-provision in the GitHub Actions container directly. * Using the submitted install script as well. * Trying as runner user. * Trying to use the ce-dev base container. * Updating key name. * Suppressing systemd actions in Docker. * Seems Ansible flags have changed. * Still trying to get --extra-vars right! * Catching Ansible Galaxy upgrade timers for docker containers. * Trying to force --roles-path for Galaxy. * Trying different quotes. * Missed a line. * Trying a different approach to passing vars. * Adding some debug. * Running ce-python debug first. * Trying moving to the ce-provision directory. * Checking the specific path to galaxy roles in ce-provision. * Trying as controller user again. * Trying to make the roles dir. * Being consistent about paths in bash. * Removing debug lines for now. * Allowing script to skip iptables. * Misnamed flag. * Adding user_provision role to configure controller user. * Wrapping cleanup so it doesn't break GitHub Actions. * Completing variables for user_provisin. * Missed the sudoers var. * Quoting vars. * GitLab installer needs _domain_name. * Logic error in clean-up script. * Fixing paths to ce-provision in container. * Trying to fix CI perms issues. * Git dubious ownership error. * Git dubious ownership error. * Running the web server test as the controller user. * Missed a controller var. * Commenting out the CE container to test. * Adding a separate step for Git actions. * Need sudo for Ubuntu. * Using a volume to persist data between steps. * Adding debug commands to test volumes. * Tweaking volumes. * Adding the checkout command back in. * Trying a different approach. * ls command looks good, so putting web build back in. * More Ansible Galaxy debug. * Trying to make ansible-galaxy detect installed roles. * Run galaxy command as controller. * Trying galaxy command and cd wrapped in su. * Specifically checking the contents of galaxy/roles. * Trying a double-tap install process. * Quick refactor and debug of SSH. * Adding OpenSSH server package. * Checking for a firewall. * Checking listening packages. * Starting SSHD especially. * Starting SSHD without systemd. * Pre-empting config a bit more. * More galaxy path debug. * Running a find to see if we can find the missing roles. * More verbosity. * Checking for missing requirements file. * Removing eroneous when clause. * Tidying up redundant debug lines. * Creating a separate ci.yml play targeting localhost. * Making sure sshd is running. * Tidying up GitLab CI file and installing SSHD. * Installing SSHD as a separate step. * SSHD already installed, starting it instead. * Don't create systemd timers in containers. * Preparing a test GitLab build. * Making builds nightly and fixing GitLab role bug. * Ensuring is_local var exists and making lock behaviour optional. * Fixing location and owner of Blackfire config so it is configurable. * Documentation update. * Removing all is defined checks for is_local since it is now always defined. * Letting GitLab know it's on Docker earlier. * Trying to run runsvdir-start to avoid container freezing. * Temporarily skipping reconfigure of GitLab to test the rest. * Trying to move GitLab reconfigure commands to CI. * Fixing service namespace for runner and reinstating GitLab tasks. * Trying to get config script working for GitLab in CI. * No systemd, do not try to restart gitlab-runner. * Removing firewall role from CI GitLab test, don't need it and it breaks CI. * Outputting PostGreSQL logs to see if there are errors. * Outputting PostGreSQL logs to see if there are errors. * Trying the config script for GitLab again. * Suppressing extra GitLab config for CI runs. * Setting Blackfire CLI defaults to use ce-dev user. * Improving GitLab vars and adding force stop feature. * Not installed aws_credentials in meta roles if AWS support disabled. * Most people will not want pam_ldap or pam_linotp, should not be in meta. * If you don't create LDAP SSL certs you might not have a /etc/ldap directory. * Adding a merge of the main branch into the docs branch to CI. * Adding comment to not use hyphens in boto profile names. * Supporting different key types to publish to AWS. * Adding a git fetch before the merge in docs publishing. * Using the safer _ce_provision_username var in AWS key role. * Adding the --allow-unrelated-histories flag to git merge in CI. * Commenting out some of the AWS ACL rulesets to leave them as examples. * Trying to pull the docs branch to ensure it is up to date. * Adding keyserver.ubuntu.com to the key servers we publish to by default in gpg_key. * CI updates and improving SOPS role. * Swapping hard coded branch names for vars in CI. * Giving up on merging 2.x - will have to try another approach. * Change of approach to Packer plugin management. * Renaming task. * Reorganising the GitLab Runner role into blocks. * Updating amazon.aws collection for Ansible. * Merging 2.x. * Adding a generic launcher playbook. * Updating default branch names to 'main'. * Adding code to launcher playbook that adds new server to hosts.yml. * Adding hosts.yml file handling to launcher.
1 parent ddc9dac commit e0888ff

File tree

11 files changed

+65
-22
lines changed

11 files changed

+65
-22
lines changed

ce-dev/ansible/vars/_common/user_deploy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
_user_deploy_username: ce-dev
22
user_deploy:
33
username: "{{ _user_deploy_username }}"
4-
utility_host: "localhost"
5-
utility_username: "{{ _user_deploy_username }}"
64
sudo_config:
75
entity_name: "{{ _user_deploy_username }}"
86
hosts: "ALL"

ce-dev/ansible/vars/_common/user_provision.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
_user_provision_username: ce-dev
22
user_provision:
33
username: "{{ _user_provision_username }}"
4-
utility_host: "localhost"
5-
utility_username: "{{ _user_provision_username }}"
64
sudo_config:
75
entity_name: "{{ _user_provision_username }}"
86
hosts: "ALL"

ce-dev/ansible/vars/gitlab/ce_deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ ce_deploy:
22
own_repository: https://github.com/codeenigma/ce-deploy.git
33
own_repository_branch: 1.x
44
username: deploy
5-
utility_username: deploy
65
local_dir: /home/deploy/ce-deploy
7-
ce_provision_dir: /home/ce-dev/ce-provision
6+
ce_provision_dir: /home/ce-dev/ce-provision

install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ fi
147147
/usr/bin/su - "$CONTROLLER_USER" -c "/usr/bin/python3 -m venv /home/$CONTROLLER_USER/ce-python"
148148
/usr/bin/su - "$CONTROLLER_USER" -c "/home/$CONTROLLER_USER/ce-python/bin/python3 -m pip install --upgrade pip"
149149
/usr/bin/su - "$CONTROLLER_USER" -c "/home/$CONTROLLER_USER/ce-python/bin/pip install ansible netaddr python-debian"
150-
/usr/bin/su - "$CONTROLLER_USER" -c "/home/$CONTROLLER_USER/ce-python/bin/ansible-galaxy collection install ansible.posix -p /home/$CONTROLLER_USER/.ansible/collections/ansible_collections --force"
151150
if [ "$AWS_SUPPORT" = "true" ]; then
152151
/usr/bin/su - "$CONTROLLER_USER" -c "/home/$CONTROLLER_USER/ce-python/bin/pip install boto3"
153152
fi
@@ -167,6 +166,8 @@ else
167166
/usr/bin/echo "-------------------------------------------------"
168167
fi
169168
/usr/bin/mkdir -p "/home/$CONTROLLER_USER/ce-provision/galaxy/roles"
169+
/usr/bin/su - "$CONTROLLER_USER" -c "cd /home/$CONTROLLER_USER/ce-provision && /home/$CONTROLLER_USER/ce-python/bin/ansible-galaxy collection install ansible.posix -p /home/$CONTROLLER_USER/ce-provision/galaxy/ansible_collections --force"
170+
170171
# Create playbook for ce-provision.
171172
/bin/cat >"/home/$CONTROLLER_USER/ce-provision/provision.yml" << EOL
172173
---
@@ -233,8 +234,6 @@ user_provision:
233234
create: false
234235
create_home: false
235236
update_password: always
236-
utility_username: "${CONTROLLER_USER}"
237-
utility_host: localhost
238237
sudo_config:
239238
entity_name: "${CONTROLLER_USER}"
240239
hosts: "ALL"

plays/launcher/configure.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# Bare provisioning of a new server.
3+
# Use this command to execute:
4+
#
5+
# cd /home/controller/ce-provision && \
6+
# ./scripts/provision.sh --workspace /home/controller/ce-provision \
7+
# --repo none --branch none \
8+
# --playbook /home/controller/ce-provision/plays/launcher/configure.yml \
9+
# --ansible-extra-vars "_provision_host=X.X.X.X"
10+
#
11+
# Replace X.X.X.X with your hostname or IP address.
12+
- hosts: localhost
13+
vars:
14+
_ce_provision_username: controller
15+
_add_host: true # set to false if you do not want to add the new server to hosts.yml
16+
_ce_provision_config_branch: 2.x # change this if you didn't use our example config and have a different main branch name
17+
tasks:
18+
- name: Add the server to Ansible hosts in memory.
19+
ansible.builtin.add_host:
20+
hostname: "{{ _provision_host }}"
21+
22+
- name: Add the server to hosts.yml.
23+
when: _add_host
24+
block:
25+
- name: Edit hosts.yml file.
26+
ansible.builtin.lineinfile:
27+
path: "/home/{{ _ce_provision_username }}/ce-provision/config/hosts/hosts.yml"
28+
line: "{{ _provision_host }}:"
29+
create: true
30+
31+
- name: Add hosts.yml changes.
32+
ansible.builtin.command: git add .
33+
args:
34+
chdir: "/home/{{ _ce_provision_username }}/ce-provision/config"
35+
36+
- name: Commit hosts.yml changes.
37+
ansible.builtin.shell: "git diff --staged --quiet || git commit -m 'Ansible autogenerated - host {{ _provision_host }} added.'"
38+
args:
39+
chdir: "/home/{{ _ce_provision_username }}/ce-provision/config"
40+
41+
- name: Push the hosts file change to the config repository.
42+
ansible.builtin.command: "git push origin {{ _ce_provision_config_branch | default('main') }}"
43+
args:
44+
chdir: "/home/{{ _ce_provision_username }}/ce-provision/config"
45+
46+
- hosts: "{{ _provision_host }}"
47+
vars:
48+
ansible_user: admin
49+
_ce_provision_build_id: 0
50+
become: true
51+
tasks:
52+
- ansible.builtin.import_role:
53+
name: _init
54+
- ansible.builtin.import_role:
55+
name: debian/user_provision
56+
- ansible.builtin.import_role:
57+
name: _exit

roles/_init/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ _venv_path: "/home/{{ _ce_provision_username }}/ce-python"
77
_venv_command: /usr/bin/python3 -m venv
88
_venv_install_username: "{{ _ce_provision_username }}"
99
_ce_ansible_timer_name: upgrade_ansible
10+
_env_type: unspecified
1011

1112
# AWS variables - if you are using an AWS account, you can preset certain variables
1213
# Generally it is recommended to place these in your ce-provision-config repository under hosts/group_vars/all

roles/debian/ce_deploy/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
ansible.builtin.git:
4848
repo: "{{ ce_deploy.own_repository | default('https://github.com/codeenigma/ce-deploy.git') }}"
4949
dest: "{{ ce_deploy.local_dir }}"
50-
version: "{{ ce_deploy.own_repository_branch | default('master') }}"
50+
version: "{{ ce_deploy.own_repository_branch | default('main') }}"
5151
update: true
5252
accept_hostkey: true
5353
become: true
@@ -58,7 +58,7 @@
5858
repo: "{{ ce_deploy.config_repository }}"
5959
accept_hostkey: true
6060
dest: "{{ _ce_provision_build_tmp_dir }}/config"
61-
version: "{{ ce_deploy.config_repository_branch | default('master') }}"
61+
version: "{{ ce_deploy.config_repository_branch | default('main') }}"
6262
become: false
6363
delegate_to: localhost
6464
when: ce_deploy.config_repository is defined and ce_deploy.config_repository

roles/debian/ce_provision/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
ansible.builtin.git:
8686
repo: "{{ ce_provision.own_repository | default('https://github.com/codeenigma/ce-provision.git') }}"
8787
dest: "{{ ce_provision.local_dir }}"
88-
version: "{{ ce_provision.own_repository_branch | default('master') }}"
88+
version: "{{ ce_provision.own_repository_branch | default('main') }}"
8989
update: true
9090
accept_hostkey: true #@todo?
9191
become: true
@@ -98,7 +98,7 @@
9898
repo: "{{ ce_provision.config_repository }}"
9999
accept_hostkey: true
100100
dest: "{{ ce_provision.local_dir }}/config"
101-
version: "{{ ce_provision.config_repository_branch | default('master') }}"
101+
version: "{{ ce_provision.config_repository_branch | default('main') }}"
102102
become: true
103103
become_user: "{{ ce_provision.username }}"
104104
when:

roles/debian/user_ansible/defaults/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ user_ansible:
1111
# This is shown for documentation, you should do this in your config repo
1212
# uid: 999
1313
# gid: 999
14-
# Local username of the deploy user.
15-
utility_host: "localhost"
16-
utility_username: "{{ _user_ansible_username }}"
1714
sudo_config: {} # an empty dictionary will skip creating a sudo config
1815
# Example sudo config allowing full sudo permissions - see the debian/sudo_config role for more details.
1916
# entity_name: "{{ _user_ansible_username }}"

roles/debian/user_deploy/defaults/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ user_deploy:
1212
# This is shown for documentation, you should do this in your config repo
1313
# uid: 989
1414
# gid: 989
15-
# Local username of the deploy user.
16-
utility_host: "localhost"
17-
utility_username: "{{ _user_deploy_username }}"
1815
sudo_config: {}
1916
# Example config allowing for feature branching. Allows manipulation of NGINX vhosts and cron.d files.
2017
# Uncomment to use.

0 commit comments

Comments
 (0)