Giter VIP home page Giter VIP logo

ansible-templates's Introduction

Ansible Templates

Some of the templates I've created to clean up my Ansible configs!

Template Functionality
docker.yaml Copies files, stops & starts docker compose
service.yaml Copies files, links .service file, stops service, reloads daemon, starts service
setup-user-docker-ssh.yaml Ensure user exists, add user to docker group, add ssh keys
sudoers-allow-service-management.yaml Allow specified user to manage specified service

How-to

Either ...

  • Copy the contents of one (or more) of the yaml files
  • Use git clone https://github.com/Denperidge/ansible-templates.git templates to get all templates

Example usage:

- name: Server setups
  hosts: servers

  tasks:
    - include_tasks: templates/docker.yaml
      vars:
        name: "Plausible"
        src: "./plausible-files/"
        dest: "/home/user/plausible"

Note: click here to view the explanation as to why no docker compose module is used

- name: Server setups
  hosts: servers

  tasks:
    - include_tasks: templates/service.yaml
      vars:
        name: "caddy"
        src: "./caddy/"
        dest: "/home/user/caddy"
        servicefile: "/home/user/caddy/caddy.service"
- name: Server elevated setups
  hosts: servers
  become_user: root
  tasks:
    - include_tasks: templates/setup-user-docker-ssh.yaml
      loop:
        - { 
          username: "root", 
          sshkeys: 
            [ 
              {comment: "Desktop pc", file: "keys/id_rsa_desktop.pub"}, 
              {comment: "Laptop", file: "keys/id_rsa_laptop.pub"}, 
            ] 
          }
        - { 
          username: "user",
          sshkeys: 
            [ 
              {comment: "Desktop pc", file: "keys/id_rsa_desktop.pub"} 
            ] 
          }
- name: Server elevated setups
  hosts: servers
  become_user: root
  tasks:
    - include_tasks: templates/sudoers-allow-service-management.yaml
      vars:
        user: user
        servicename: caddy
        servicefile: "/home/user/caddy/caddy.service"

Discussions

No docker compose module usage

The docker Ansible-maintained Docker Compose modules as of writing have no support for Docker Compose v2 or above. Hence currently a manual solution is used. If I find a good external module/solution, I'll hopefully implement that down the line. (In case you know of one, please feel free to open an Issue and let me know!)

License

Ansible is licensed under GNU GPLv3. You can view the full license on the Ansible GitHub repository.

These templates are released into the public domain through the Unlicense. You can view the LICENSE file in this repository here.

ansible-templates's People

Contributors

denperidge avatar

Watchers

 avatar

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.