Added Nix Flake
This commit is contained in:
parent
c6beaf693e
commit
5ecbb4dae6
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
||||
.ansible/
|
||||
.venv/
|
||||
|
@ -4,15 +4,10 @@ A template for an Ansible repository
|
||||
|
||||
# Requirements
|
||||
|
||||
You need to have `ssh` and `python3` installed. If you want to access a server using username and password you need to install `sshpass` as well
|
||||
|
||||
To use this repository run:
|
||||
|
||||
```sh
|
||||
git clone https://git.nicolabelluti.me/nicolabelluti/template-ansible
|
||||
cd template-ansible
|
||||
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
nix develop
|
||||
```
|
||||
|
@ -9,7 +9,7 @@ nocows = true
|
||||
inventory = ./inventory
|
||||
|
||||
# (string) Sets the macro for the 'ansible_managed' variable available for :ref:`ansible_collections.ansible.builtin.template_module` and :ref:`ansible_collections.ansible.windows.win_template_module`. This is only relevant for those two modules.
|
||||
ansible_managed = This file was last modified by {{{{ '{uid}' | replace('-', ' ') | title }}}} on %Y-%m-%d %H:%M. The template for this file can be found under {{{{ template_fullpath | relpath }}}}
|
||||
ansible_managed = This file is managed with Ansible
|
||||
|
||||
# (pathspec) Colon separated paths in which Ansible will search for Roles.
|
||||
roles_path = ./roles
|
||||
|
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1714906307,
|
||||
"narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
25
flake.nix
Normal file
25
flake.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
description = "Ansible";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
openssh
|
||||
sshpass
|
||||
|
||||
ansible
|
||||
ansible-lint
|
||||
];
|
||||
|
||||
};
|
||||
};
|
||||
}
|
@ -4,4 +4,4 @@
|
||||
- name: Test Role
|
||||
role: test_role
|
||||
vars:
|
||||
lorem_ipsum_string: Lorem Ipsum is simply dummy text
|
||||
test_role__lorem_ipsum_string: Lorem Ipsum is simply dummy text
|
||||
|
@ -1,2 +0,0 @@
|
||||
ansible ~= 8.3.0
|
||||
ansible-lint ~= 6.18.0
|
@ -4,7 +4,7 @@ A brief description about the role...
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Is Required? | Default |
|
||||
|:--------------------:|:------------:|:-------------:|
|
||||
| `hello_world_string` | ✔️ | Hello, World! |
|
||||
| `lorem_ipsum_string` | ❌ | |
|
||||
| Name | Is Required? | Default |
|
||||
|:-------------------------------:|:------------:|:-------------:|
|
||||
| `test_role__hello_world_string` | ✔️ | Hello, World! |
|
||||
| `test_role__lorem_ipsum_string` | ❌ | |
|
||||
|
@ -1 +1 @@
|
||||
hello_world_string: Hello, World!
|
||||
test_role__hello_world_string: Hello, World!
|
||||
|
@ -3,9 +3,10 @@
|
||||
|
||||
- name: Print an "Hello, World!"
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ hello_world_string }}"
|
||||
msg: "{{ test_role__hello_world_string }}"
|
||||
|
||||
- name: Test the `ansible_managed` variable
|
||||
ansible.builtin.template:
|
||||
dest: /tmp/ansible.txt
|
||||
src: ansible.txt.j2
|
||||
src: ansible.txt.j2
|
||||
mode: preserve
|
||||
|
@ -1,3 +1,3 @@
|
||||
# {{ ansible_managed }}
|
||||
{{ ansible_managed | comment('plain') }}
|
||||
|
||||
{{ lorem_ipsum_string }}
|
||||
{{ test_role__lorem_ipsum_string }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user