cleaned up whats moved to lib.sls
This commit is contained in:
parent
9e4da0f7f7
commit
9bd83adf8b
@ -1,60 +0,0 @@
|
||||
{% set user = salt['pillar.get']('podman:user', 'root') %}
|
||||
{% set home = salt['user.info'](user).home %}
|
||||
{% set group = salt['pillar.get']('podman:group', 'root') %}
|
||||
|
||||
|
||||
|
||||
{% for name, args in salt['pillar.get']('containers', {} ).items() %}
|
||||
|
||||
Create container manage file for {{ name }}:
|
||||
file.managed:
|
||||
- name: "{{ home }}/bin/{{ name }}.sh"
|
||||
- source: salt://podman/files/container.sh.jinja
|
||||
- template: jinja
|
||||
- user: {{ user }}
|
||||
- group: {{ group }}
|
||||
- mode: "0750"
|
||||
- context:
|
||||
container: {{ name }}
|
||||
args: {{ args }}
|
||||
|
||||
{% if args['volumes'] is defined %}
|
||||
{% for volume, mount in args['volumes'].items() %}
|
||||
Create {{ volume }} volume for {{ name }}:
|
||||
cmd.run:
|
||||
- name: podman volume create {{ name }}-{{ volume }}
|
||||
- runas: {{ user }}
|
||||
- unless: podman volume exists {{ name }}-{{ volume }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
Create container {{ name }}:
|
||||
cmd.run:
|
||||
- name: "{{ home }}/bin/{{ name }}.sh --create"
|
||||
- runas: {{ user }}
|
||||
- unless: podman container exists {{ name }}
|
||||
|
||||
Create container {{ name }} unit file:
|
||||
cmd.run:
|
||||
- name: podman generate systemd --name {{ name }} > {{ home }}/.config/systemd/user/{{ name }}.service
|
||||
- runas: {{ user }}
|
||||
- onchanges:
|
||||
- cmd: Create container {{ name }}
|
||||
|
||||
Run user daemon reload for {{ name }} unit:
|
||||
cmd.run:
|
||||
- name: systemctl --user daemon-reload
|
||||
- runas: {{ user }}
|
||||
- onchanges:
|
||||
- cmd: Create container {{ name }} unit file
|
||||
|
||||
start container {{ name }}:
|
||||
cmd.run:
|
||||
- name: "{{ home }}/bin/{{ name }}.sh --start"
|
||||
- runas: {{ user }}
|
||||
- unless: "{{ home }}/bin/{{ name }}.sh --is-running"
|
||||
- onchanges:
|
||||
- cmd: Run user daemon reload for {{ name }} unit
|
||||
|
||||
|
||||
{% endfor %}
|
@ -1,20 +0,0 @@
|
||||
{% set zone = salt['pillar.get']('containers:zone', 'public') %}
|
||||
|
||||
{% for name, args in salt['pillar.get']('containers', {} ).items() %}
|
||||
{% if args['ports'] is defined %}
|
||||
|
||||
Defining firewalld service for {{ name }}:
|
||||
firewalld.service:
|
||||
- name: {{ name }}
|
||||
- ports:
|
||||
{%- for port in args['ports'] %}
|
||||
- {{ port['host'] }}/tcp
|
||||
{%- endfor %}
|
||||
|
||||
adding service {{ name }} to {{ zone }} zone:
|
||||
firewalld.present:
|
||||
- name: {{ zone }}
|
||||
- services:
|
||||
- {{ name }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
Reference in New Issue
Block a user