mirror of
https://github.com/morten-olsen/configs.git
synced 2026-02-08 00:46:24 +01:00
improved context system
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
install_with_root: true
|
||||
terminal_casks: []
|
||||
pkgs: []
|
||||
contexts: {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: Copy config {{ context }}
|
||||
- name: Setup directories
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.file:
|
||||
@@ -7,25 +7,12 @@
|
||||
path: "{{ home }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
- ../files/
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'directory'
|
||||
|
||||
- name: "Copy templates : {{ context }}"
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ home }}/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../templates/{{ context }}
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
- name: Copy config {{ context }}
|
||||
- name: Copy config
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.copy:
|
||||
@@ -33,7 +20,7 @@
|
||||
dest: "{{ home }}/{{ item.path }}"
|
||||
mode: "{{ item.mode }}"
|
||||
with_community.general.filetree:
|
||||
- ../files/{{ context }}
|
||||
- ../files
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
when: item.state == 'file'
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
ansible.builtin.package:
|
||||
name: "{{ terminal_pkgs }}"
|
||||
|
||||
- name: "Install casks : {{ context }}"
|
||||
- name: "Install casks"
|
||||
tags:
|
||||
- install
|
||||
when: terminal_casks
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
---
|
||||
- name: Install context dependencies
|
||||
- name: Install dependencies
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Configure contexts
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
loop: "{{ contexts }}"
|
||||
loop_control:
|
||||
loop_var: context
|
||||
- name: Configure
|
||||
tags:
|
||||
- config
|
||||
ansible.builtin.include_tasks: config.yml
|
||||
|
||||
- name: Setup contexts
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
include_tasks: "setup-context.yml"
|
||||
vars:
|
||||
name: "{{ item.key }}"
|
||||
context: "{{ item.value }}"
|
||||
loop: "{{ contexts | dict2items }}"
|
||||
loop_control:
|
||||
label: "{{ item.key }}"
|
||||
|
||||
12
playbooks/roles/base_terminal/tasks/setup-context.yml
Normal file
12
playbooks/roles/base_terminal/tasks/setup-context.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
- name: Setup context env
|
||||
tags:
|
||||
- git
|
||||
- config
|
||||
ansible.builtin.template:
|
||||
src: "../templates/envrc.context.j2"
|
||||
dest: "{{ context.path }}/.envrc"
|
||||
mode: "600"
|
||||
vars:
|
||||
env: "{{ context.env}}"
|
||||
name: "{{ name }}"
|
||||
when: "'env' in context"
|
||||
4
playbooks/roles/base_terminal/templates/envrc.context.j2
Normal file
4
playbooks/roles/base_terminal/templates/envrc.context.j2
Normal file
@@ -0,0 +1,4 @@
|
||||
{% for key in env %}
|
||||
export {{ key }}="{{ env[key] }}"
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user