Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate just roles as pre-task on localhost #170

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions init.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
- name: Set up a self-hosted server
hosts: localhost
become: false
tasks:
- name: Pull latest changes from Git repository
shell: "git --work-tree={{ playbook_dir }} --git-dir={{ playbook_dir }}/.git pull"
args:
executable: /bin/bash
register: git_pull_output
environment:
GIT_ASKPASS: echo
GIT_TERMINAL_PROMPT: 0
tags:
- git
-
when: "'git' in ansible_run_tags"


- name: Display Git pull output
debug:
var: git_pull_output.stdout_lines
tags:
- git
when: "'git' in ansible_run_tags"


- name: Run 'just optimize-reset'
command: just optimize-reset
args:
chdir: "{{ playbook_dir }}"
register: optimize_output
tags:
- optimize-reset
when: "'optimize-reset' in ansible_run_tags"

- name: Run 'just optimize'
command: just optimize
args:
chdir: "{{ playbook_dir }}"
register: optimize_output
tags:
- optimize
when: "'optimize-reset' not in ansible_run_tags and 'optimize' in ansible_run_tags"


- name: Display optimize output
debug:
var: optimize_output.stdout_lines
tags:
- optimize
when: "'optimize-reset' not in ansible_run_tags and 'optimize' in ansible_run_tags"


- name: Run 'just roles'
command: just roles
args:
chdir: "{{ playbook_dir }}"
register: roles_output
tags:
- roles
when: "'roles' in ansible_run_tags"

- name: Display roles output
debug:
var: roles_output.stdout_lines
tags:
- roles
when: "'roles' in ansible_run_tags"

- name: Run 'just install-all'
command: just install-all
args:
chdir: "{{ playbook_dir }}"
register: install_output
tags:
- install
when: "'setup' not in ansible_run_tags and 'install' in ansible_run_tags"

- name: Display install-all output
debug:
var: install_output.stdout_lines
tags:
- install
when: "'setup' not in ansible_run_tags and 'install' in ansible_run_tags"


- name: Run 'just setup-all'
command: just setup-all
args:
chdir: "{{ playbook_dir }}"
register: setup_output
tags:
- setup
when: "'install' not in ansible_run_tags and 'setup' in ansible_run_tags"


- name: Display setup-all output
debug:
var: setup_output.stdout_lines
tags:
- setup
when: "'install' not in ansible_run_tags and 'setup' in ansible_run_tags"
24 changes: 24 additions & 0 deletions roles/mash/just_roles/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

- name: Copy requirements.yml to playbook directory
copy:
src: "{{ playbook_dir }}/templates/requirements.yml"
dest: "{{ playbook_dir }}/requirements.yml"
force: yes

- name: Copy setup.yml to playbook directory
copy:
src: "{{ playbook_dir }}/templates/setup.yml"
dest: "{{ playbook_dir }}/setup.yml"
force: yes

- name: Copy group_vars_mash_servers.yml to playbook directory
copy:
src: "{{ playbook_dir }}/templates/group_vars_mash_servers"
dest: "{{ playbook_dir }}/group_vars/mash_servers"
force: yes

- name: Change directory to the playbook directory
shell: /usr/bin/just roles
args:
chdir: "{{ playbook_dir }}"
9 changes: 9 additions & 0 deletions templates/setup.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
- name: "Pre-Task on localhost"
hosts: localhost
gather_facts: yes
become: no
roles:
- role: mash/just_roles
tags:
- roles

- name: "Set up a self-hosted server"
hosts: "{{ target if target is defined else 'mash_servers' }}"
become: true
Expand Down