Git Product home page Git Product logo

ansible-systemd-conf's Introduction

ansible-systemd-conf's People

Contributors

aruhier avatar shibumi avatar tszym avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-systemd-conf's Issues

Use variables for systemd_conf_service + systemd_conf_timer

I'd like to name systemd-timer and service via a variable: I have an ansible role restic_backup_generic which depends on shibumi.systemd-conf and we set restic_backup_generic_backup_name as the backup job name. This is what we tried in restic_backup_generic/meta/main.yml:

---
dependencies:
  - role: shibumi.systemd-conf
    systemd_conf_service:
      "restic-backup-{{ restic_backup_generic_backup_name }}":
        - Unit:
          - Description: "Generic restic backup {{ restic_backup_generic_backup_name }}"
        - Service:
          - Type: "oneshot"
          - ExecStart: "/usr/local/sbin/restic-backup-{{ restic_backup_generic_backup_name }}"
    systemd_conf_timer:
      "restic-backup-{{ restic_backup_generic_backup_name }}":
        - Unit:
          - Description: "Daily generic restic backup {{ restic_backup_generic_backup_name }}"
        - Timer:
          - OnCalendar: "*-*-* 21:00"
          - Persistent: "True"
        - Install:
          - WantedBy: "timers.target"

My playbook.yml looks something like this:

---
- hosts: hostname.example.com
  become: yes
  roles:
    - role: restic_backup_generic
      restic_backup_generic_backup_name: samba-data
      restic_backup_generic_backup_path:
        - "/srv/samba/data01"

Unfortunately the systemd service and timer are literally called restic-backup-{{ restic_backup_generic_backup_name }}.*. The variable does not get expanded. Any idea how to solve this?

Thx for your help and support this role!

How to enable and start a service / timer?

It seems like there is no way to enable and/or start defined service / timer with this role, right?

Currently I do something like this:

  roles:
    - role: systemd-conf
      systemd_conf_timer:
        restic-backup-prune:
          - Unit:
            - Description: "Weekly restic backup prune"
          - Timer:
            - OnCalendar: "Sun *-*-* 12:00"
            - Persistent: "True"
          - Install:
            - WantedBy: "timers.target"
      systemd_conf_service:
        restic-backup-prune:
          - Unit:
            - Description: "Weekly restic backup prune"
          - Service:
            - Type: "oneshot"
            - ExecStart: "/usr/local/bin/restic --password-file /root/.restic_data_password -r /srv/backups/restic/backup01 forget --keep-daily 30 --keep-weekly 8 --keep-monthly 12 --keep-yearly 75 --keep-last 60 --prune"
  tasks:
    - name: "Enable and start timers/services"
      service:
        name:  restic-backup-prune.timer
        state: started
        enabled: true

Is there a better way to this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.