{"id":864,"date":"2024-06-15T10:30:15","date_gmt":"2024-06-15T10:30:15","guid":{"rendered":"https:\/\/blog.fisher.hu\/blogv4\/?p=864"},"modified":"2024-06-15T10:49:33","modified_gmt":"2024-06-15T10:49:33","slug":"ansible-semaphore-systemd","status":"publish","type":"post","link":"https:\/\/blog.fisher.hu\/blogv4\/2024\/06\/15\/ansible-semaphore-systemd\/","title":{"rendered":"Ansible Semaphore &#8211; systemd"},"content":{"rendered":"\n<p>So you want to use semaphore and shocked because the installer has no any startup script?<\/p>\n\n\n\n<p>Yes, I know the feeling.<\/p>\n\n\n\n<p>After a copy-paste of a existing unit file I realized it is outdated and fundamentally silly, so I have to make my own anyway.<\/p>\n\n\n\n<p>Also wanted to play with some github actions, so ended up with a automatically updated public repo.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/fisherhu\/fisher-unix-public\/tree\/main\/semaphore-systemd\">So here we are<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">#!\/bin\/bash\n\nDEFCONFIG=\"\/etc\/default\/ansible-semaphore\"\nETCFILE=\"\/etc\/ansible-semaphore\/semaphore_config.json\"\n\n\nif [ \"$(hostname)\" != \"semaphore0\" ]\nthen\n  echo \"Run on semaphore0 as root.\"\n  exit 1\nfi\n\n\nif [ ! -f \"${ETCFILE}\" ]\nthen\n echo \"No config file deployed, fix it please.\"\nfi\n\nif [ ! -f \"${DEFCONFIG}\" ]\nthen\n echo '#Ansible Semaphore Defaults'                 > \"${DEFCONFIG}\"\n echo \"SEMAPHORE_CONFIG=${ETCFILE}\"                >> \"${DEFCONFIG}\"\nfi\n\ncat > \/etc\/systemd\/system\/semaphore.service <<'EOF'\n[Unit]\nDescription=Ansible Semaphore\n\n\n[Service]\nType=forking\nEnvironmentFile=-\/etc\/default\/ansible-semaphore\nExecStart=\/bin\/sh -c \"\/usr\/bin\/semaphore server --config ${SEMAPHORE_CONFIG}&\"\nRestart=always\nRestartSec=10s\n\n[Install]\nWantedBy=multi-user.target\n\nEOF\n\nsystemctl daemon-reload\nsystemctl enable --now semaphore\n\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">#!\/bin\/bash\n\n\nsystemctl disable --now semaphore\n\nrm \/etc\/systemd\/system\/semaphore.service\n\nsystemctl daemon-reload\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>So you want to use semaphore and shocked because the installer has no any startup script? Yes, I know the feeling. After a copy-paste of a existing unit file I realized it is outdated and fundamentally silly, so I have to make my own anyway. Also wanted to play with some github actions, so ended up with a automatically updated public repo. So here we&#8230; <\/p>\n<p class=\"more\"><a class=\"more-link\" href=\"https:\/\/blog.fisher.hu\/blogv4\/2024\/06\/15\/ansible-semaphore-systemd\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[176,133,177,175,178],"class_list":["post-864","post","type-post","status-publish","format-standard","hentry","category-blog","tag-ansiblem","tag-github","tag-semaphore","tag-systemd","tag-unix","is-cat-link-border-bottom"],"_links":{"self":[{"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/posts\/864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/comments?post=864"}],"version-history":[{"count":8,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/posts\/864\/revisions"}],"predecessor-version":[{"id":874,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/posts\/864\/revisions\/874"}],"wp:attachment":[{"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/media?parent=864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/categories?post=864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fisher.hu\/blogv4\/wp-json\/wp\/v2\/tags?post=864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}