forked from theforeman/foreman_ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #25009 - fix sync script and sync templates (theforeman#209)
- Loading branch information
Showing
3 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
app/views/foreman_ansible/job_templates/module_action_-_ansible_default.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<%# | ||
kind: job_template | ||
name: Module Action - Ansible Default | ||
model: JobTemplate | ||
job_category: Ansible Modules | ||
description_format: "Module %{action} %{module_spec}" | ||
provider_type: Ansible | ||
template_inputs: | ||
- name: pre_script | ||
description: A script to run prior to the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
- name: action | ||
description: 'The module action enable, install etc' | ||
input_type: user | ||
required: true | ||
options: "\nlist\ninfo\nenable\ndisable\ninstall\nupdate\nremove\nprovides\nlock\nunlock\nprofile\nstreams" | ||
- name: module_spec | ||
description: The module specification. module:stream/profile | ||
input_type: user | ||
required: false | ||
- name: options | ||
description: Other optional flags for the action | ||
input_type: user | ||
required: false | ||
- name: post_script | ||
description: A script to run after the module action | ||
input_type: user | ||
required: false | ||
advanced: true | ||
%> | ||
|
||
<% command = "dnf -y module #{input(:action)} #{input(:module_spec)} #{input(:options)}" %> | ||
|
||
--- | ||
- hosts: all | ||
<%- if input('pre_script').present? -%> | ||
pre_tasks: | ||
- shell: "<%= input('pre_script') %>" | ||
<%- end -%> | ||
tasks: | ||
- shell: | | ||
<%= indent(8) { command } %> | ||
register: out | ||
args: | ||
warn: false | ||
- debug: var=out | ||
<%- if input('post_script').present? -%> | ||
post_tasks: | ||
- shell: "<%= input('post_script') %>" | ||
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,41 @@ | ||
#!/bin/bash | ||
# | ||
# Copies unattended templates from community-templates repository to | ||
# app/views/unattended/ where they can be seeded on new installations. | ||
# Copies job templates from community-templates repository to | ||
# app/views/foreman_ansbile/job_templates so they can be seeded on new | ||
# installations. | ||
# | ||
# Not intended for use on existing installations, only for development. | ||
# Production installations should use the foreman_templates plugin to | ||
# update the contents of the database. | ||
# Part of the release process. | ||
|
||
REPO=$(mktemp -d) | ||
trap "rm -rf $REPO" EXIT | ||
shopt -s extglob | ||
|
||
git clone -q -b develop \ | ||
https://github.com/theforeman/community-templates $REPO/ct | ||
git clone -q -b develop https://github.com/theforeman/community-templates $REPO/ct | ||
|
||
# move into destination dir if run from Foreman root | ||
[ -d app/views/foreman_ansible/ ] && cd app/views/foreman_ansible/ | ||
pushd $PWD | ||
cd $REPO/ct/job_templates | ||
|
||
rsync -am \ | ||
--include='*ansible*' \ | ||
--exclude='*' \ | ||
$REPO/ct/job_templates/* ./job_templates | ||
# Delete all non-ansible templates and remove suffix | ||
rm !(*_-_ansible_default.erb) | ||
|
||
popd | ||
|
||
# Move into destination dir if run from plugin root | ||
[ -d app/views/templates/ssh ] && cd app/views/templates/ssh | ||
[ -d app/views/foreman_ansible/job_templates/ ] && cd app/views/foreman_ansible/job_templates/ | ||
|
||
rsync -r \ | ||
--exclude README.md \ | ||
--exclude '.*' \ | ||
--exclude test \ | ||
--exclude Rakefile \ | ||
$REPO/ct/job_templates/*.erb ./ | ||
|
||
cd - | ||
|
||
git status -- app/views/foreman_ansible/job_templates | ||
|
||
if [ $(git status --porcelain -u -- app/views/foreman_ansible/job_templates | grep -c '^\?') -gt 0 ]; then | ||
echo | ||
echo "Warning: new files copied, be sure to commit them and ensure they are seeded." | ||
fi |