So following on from the Ansible Semaphore page here
There’s an easier and much quicker way to install Ansible Semaphore. Plus you’re not constrained to Docker so you can install additional packages to control windows pcs which was one of the issues I had went using the Docker way.
So all you’ll need is an installation of ansible either on the Pi or on another machine and then run this ansible playbook.
All you need to do is change this where it says “changeme”
1
2
3
4
5
6
7
8
9
10
# change the changeme entries to what ever you want.
# the login goes by the email so don't make another user with the same email.
- name: Add semaphore admin user
ansible.builtin.shell: |
sudo /snap/bin/semaphore user add --admin \
--login changeme \
--name=changeme \
[email protected] \
--password=changeme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- hosts: all
gather_facts: true
become: true
become_user: root
tasks:
# update ubuntu server
- name: Update apt repo and cache on all Debian/Ubuntu boxes
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
# install ansible
- name: install pip3
apt: name=python3-pip state=present
- name: Install Ansible.
ansible.builtin.pip:
name: ansible
# install git
- name: install git
apt: name=git state=present
- name: install snap
apt: name=snapd state=present
- name: Reboot host and wait for it to restart
reboot:
msg: "Reboot initiated by Ansible"
connect_timeout: 5
reboot_timeout: 600
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: whoami
- name: Install semaphore
community.general.snap:
name:
- semaphore
- name: start semaphore admin user
ansible.builtin.shell: |
sudo snap start semaphore
# - name: stop semaphore
# ansible.builtin.shell: |
# sudo snap stop semaphore
- name: Add semaphore admin user
ansible.builtin.shell: |
sudo /snap/bin/semaphore user add --admin \
--login changeme \
--name=changeme \
[email protected] \
--password=changeme
- name: start semaphore admin user
ansible.builtin.shell: |
sudo snap start semaphore
Installing python packages into Semaphore
One problem I had was controlling Windows machines. It kept saying that I needed to have WinRM installed. The only problem was that I already had “pywinrm>=0.2.2” installed on the pi.
I discovered that I needed to install the pip package into the snap directory.
Use this command to install inside ansible-semaphore.
1
pip install --target=/root/snap/semaphore/common/ansible_env/lib/python3.8/site-packages pywinrm>=0.2.2 --upgrade