{"id":19402109,"url":"https://github.com/robertdebock/ansible-role-service","last_synced_at":"2025-10-29T13:46:52.230Z","repository":{"id":40548451,"uuid":"171728602","full_name":"robertdebock/ansible-role-service","owner":"robertdebock","description":"Add custom services to your Linux system.","archived":false,"fork":false,"pushed_at":"2025-03-06T16:19:41.000Z","size":239,"stargazers_count":10,"open_issues_count":2,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T10:16:42.092Z","etag":null,"topics":["ansible","molecule","playbook","service","system","tox"],"latest_commit_sha":null,"homepage":"https://robertdebock.nl/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertdebock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"robertdebock"}},"created_at":"2019-02-20T18:38:15.000Z","updated_at":"2025-04-04T12:47:28.000Z","dependencies_parsed_at":"2023-02-15T08:01:57.541Z","dependency_job_id":"69a87411-9bc8-4931-87bf-5c929f1b7cbf","html_url":"https://github.com/robertdebock/ansible-role-service","commit_stats":null,"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertdebock%2Fansible-role-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertdebock","download_url":"https://codeload.github.com/robertdebock/ansible-role-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250582841,"owners_count":21453917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","molecule","playbook","service","system","tox"],"created_at":"2024-11-10T11:21:42.658Z","updated_at":"2025-10-29T13:46:52.211Z","avatar_url":"https://github.com/robertdebock.png","language":"Shell","funding_links":["https://github.com/sponsors/robertdebock"],"categories":[],"sub_categories":[],"readme":"# [Ansible role service](#ansible-role-service)\n\nAdd custom services to your Linux system.\n\n|GitHub|GitLab|Downloads|Version|\n|------|------|---------|-------|\n|[![github](https://github.com/robertdebock/ansible-role-service/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-service/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-service/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-service)|[![downloads](https://img.shields.io/ansible/role/d/robertdebock/service)](https://galaxy.ansible.com/robertdebock/service)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-service.svg)](https://github.com/robertdebock/ansible-role-service/releases/)|\n\n## [Example Playbook](#example-playbook)\n\nThis example is taken from [`molecule/default/converge.yml`](https://github.com/robertdebock/ansible-role-service/blob/master/molecule/default/converge.yml) and is tested on each push, pull request and release.\n\n```yaml\n---\n- name: Converge\n  hosts: all\n  become: true\n  gather_facts: true\n\n  vars:\n    _service_test_command:\n      default: /usr/bin/sleep\n      Alpine: /bin/sleep\n      Debian: /bin/sleep\n      Ubuntu-16: /bin/sleep\n      Ubuntu-18: /bin/sleep\n    service_test_command: \"{{ _service_test_command[ansible_distribution ~ '-' ~ ansible_distribution_major_version] | default(_service_test_command[ansible_os_family] | default(_service_test_command['default'])) }}\"  # noqa 204 Just long.\n\n  roles:\n    - role: robertdebock.service\n      service_list:\n        - name: simple-service\n          description: Simple Service\n          start_command: \"{{ service_test_command }} 3600\"\n          state: started\n          enabled: true\n        - name: stopped-service\n          description: Simple Service\n          start_command: \"{{ service_test_command }} 3601\"\n          state: stopped\n          enabled: false\n        - name: specific-stop-service\n          description: Specific Stop Service\n          start_command: \"{{ service_test_command }} 1440\"\n          stop_command: /usr/bin/killall -f \"sleep 1440\"\n        - name: specific-user-group-service\n          description: Specific User Group Service\n          start_command: \"{{ service_test_command }} 28800\"\n          user_name: root\n          group_name: root\n        - name: specific-workingdirectory-service\n          description: Specific WorkingDirectory Service\n          start_command: \"{{ service_test_command }} 57600\"\n          working_directory: /tmp\n        - name: specific-pattern-service\n          description: Specific Status Pattern Service\n          start_command: \"{{ service_test_command }} 115200\"\n          status_pattern: 115200\n        - name: variable-service\n          description: Service with environment variables\n          start_command: \"{{ service_test_command }} ${time}\"\n          environment_variables:\n            time: 230400\n        - name: pidfile-service\n          description: Service with pidfile\n          start_command: \"{{ service_test_command }} 460800\"\n          pidfile: /var/run/pidfile-service.pid\n        - name: environmentfile-service\n          description: Service with environmentfile\n          start_command: \"{{ service_test_command }} 921600\"\n          environmentfile: /environmentfile.txt\n        - name: reload-service\n          description: Service with reload command\n          start_command: \"{{ service_test_command }} 1843200\"\n          reload_command: \"kill -HUP $MAINPID\"\n          state: started\n          enabled: true\n```\n\nThe machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/robertdebock/ansible-role-service/blob/master/molecule/default/prepare.yml):\n\n```yaml\n---\n- name: Prepare\n  hosts: all\n  become: true\n  gather_facts: false\n  serial: 30%\n\n  roles:\n    - role: robertdebock.bootstrap\n\n  post_tasks:\n    - name: Place /environmentfile.txt\n      ansible.builtin.copy:\n        content: \"value=variable\"\n        dest: /environmentfile.txt\n        mode: \"0644\"\n```\n\nAlso see a [full explanation and example](https://robertdebock.nl/how-to-use-these-roles.html) on how to use these roles.\n\n## [Role Variables](#role-variables)\n\nThe default values for the variables are set in [`defaults/main.yml`](https://github.com/robertdebock/ansible-role-service/blob/master/defaults/main.yml):\n\n```yaml\n---\n# defaults file for service\n\n# service_list can contain a list of services to add to the system.\n# The mandatory items for each item are:\n# - name: The (short) name of the service, i.e. \"tomcat\".\n# - description: A bit longer name, i.e. \"Tomcat application server\".\n# - start_command: The command to start the daemon,\n#   i.e. \"/usr/local/bin/java -jar some.jar\"\n# The optional items are:\n# - stop_command: By default the program that is started is found and stopped.\n#   in case a running program is renamed or expanded (including a path) during\n#   startup, you can specify a custom stop command here, i.e. \"pkill foo\"\n# - status_pattern: What program (or pattern) to look for when finding the\n#   status of a program, i.e. \"artifactory\".\n# - type: How the program starts; \"simple\" or \"forking\". Simple means the\n#   program runs on the foreground, i.e. \"nc -l 1234\". Forking means the\n#   program itself forks, i.e. \"nc -l 12345 \u0026\"\n# - working_directory: The directory to cd into before starting the service.\n# - environment_variables: A list for variables to set. for example:\n#   environment_variables:\n#     variable1: value1\n#     variable2: value2\n# - after: Start after the mentioned service.\n# - restart_mode: The mode to use, for example \"always\".\n# - restart_seconds: The time to allow restart to finish.\n# - reload_command: Custom command to reload the service configuration.\n#   This is useful for services that support configuration reloading\n#   without a full restart, i.e. \"kill -HUP $MAINPID\"\nservice_list: []\n```\n\n## [Requirements](#requirements)\n\n- pip packages listed in [requirements.txt](https://github.com/robertdebock/ansible-role-service/blob/master/requirements.txt).\n\n## [State of used roles](#state-of-used-roles)\n\nThe following roles are used to prepare a system. You can prepare your system in another way.\n\n| Requirement | GitHub | GitLab |\n|-------------|--------|--------|\n|[robertdebock.bootstrap](https://galaxy.ansible.com/robertdebock/bootstrap)|[![Build Status GitHub](https://github.com/robertdebock/ansible-role-bootstrap/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bootstrap/actions)|[![Build Status GitLab](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bootstrap)|\n\n## [Context](#context)\n\nThis role is part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information.\n\nHere is an overview of related roles:\n![dependencies](https://raw.githubusercontent.com/robertdebock/ansible-role-service/png/requirements.png \"Dependencies\")\n\n## [Compatibility](#compatibility)\n\nThis role has been tested on these [container images](https://hub.docker.com/u/robertdebock):\n\n|container|tags|\n|---------|----|\n|[EL](https://hub.docker.com/r/robertdebock/enterpriselinux)|9|\n|[Debian](https://hub.docker.com/r/robertdebock/debian)|all|\n|[Fedora](https://hub.docker.com/r/robertdebock/fedora)|all|\n|[Ubuntu](https://hub.docker.com/r/robertdebock/ubuntu)|all|\n\nThe minimum version of Ansible required is 2.12, tests have been done on:\n\n- The previous version.\n- The current version.\n- The development version.\n\nIf you find issues, please register them on [GitHub](https://github.com/robertdebock/ansible-role-service/issues).\n\n## [License](#license)\n\n[Apache-2.0](https://github.com/robertdebock/ansible-role-service/blob/master/LICENSE).\n\n## [Author Information](#author-information)\n\n[robertdebock](https://robertdebock.nl/)\n\nPlease consider [sponsoring me](https://github.com/sponsors/robertdebock).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertdebock%2Fansible-role-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertdebock%2Fansible-role-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertdebock%2Fansible-role-service/lists"}