Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Git Hooks for Ansible Encryption
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
Git Hooks for Ansible Encryption
Compare revisions
fa8b8574908d4a0f478f38a57f31b872e9698a37 to 9b65faadbe787c93c8a88bf9473d5d4e8b79aff3
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
ahorn/git-hooks-for-ansible-encryption
Select target project
No results found
9b65faadbe787c93c8a88bf9473d5d4e8b79aff3
Select Git revision
Branches
master
Swap
Target
ahorn/git-hooks-for-ansible-encryption
Select target project
ahorn/git-hooks-for-ansible-encryption
1 result
fa8b8574908d4a0f478f38a57f31b872e9698a37
Select Git revision
Branches
master
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
adds support for custom hooks path
· 64e94865
Andreas Horn
authored
5 months ago
Unverified
64e94865
adds .gitignore
· 9b65faad
Andreas Horn
authored
5 months ago
Unverified
9b65faad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
post-commit
+5
-3
5 additions, 3 deletions
post-commit
pre-commit
+6
-3
6 additions, 3 deletions
pre-commit
with
12 additions
and
6 deletions
.gitignore
0 → 100644
View file @
9b65faad
/.venv/
This diff is collapsed.
Click to expand it.
post-commit
View file @
9b65faad
...
@@ -16,6 +16,8 @@ cyan='\033[0;36m'
...
@@ -16,6 +16,8 @@ cyan='\033[0;36m'
clear
=
'\033[0m'
clear
=
'\033[0m'
patternsFile
=
.files-for-encryption
patternsFile
=
.files-for-encryption
# get the used hooks path and remove the trailing slash
hooksPath
=
$((
git config core.hooksPath
||
echo
".git/hooks/"
)
|
sed
's:/*$::'
)
VERBOSE
=
false
VERBOSE
=
false
# Function to print verbose messages
# Function to print verbose messages
...
@@ -27,7 +29,7 @@ verbose() {
...
@@ -27,7 +29,7 @@ verbose() {
# function to activate the virtual environment
# function to activate the virtual environment
activate
()
{
activate
()
{
.
.git/
hooks/.venv/bin/activate
.
$
hooks
Path
/
.venv/bin/activate
}
}
# check for "$ANSIBLE_VAULT"
# check for "$ANSIBLE_VAULT"
...
@@ -53,7 +55,7 @@ patterns=$(<$patternsFile)
...
@@ -53,7 +55,7 @@ patterns=$(<$patternsFile)
activate
activate
# match the files for decryption
# match the files for decryption
files
=
$(
python
.git/
hooks/get-matched-files-for-encryption.py
$patternsFile
.
)
files
=
$(
python
$
hooks
Path
/get-matched-files-for-encryption.py
$patternsFile
.
)
echo
-
e
"
${
blue
}
files to decrypt:
${
clear
}
"
echo
-
e
"
${
blue
}
files to decrypt:
${
clear
}
"
for
file
in
$files
;
do
for
file
in
$files
;
do
...
@@ -72,7 +74,7 @@ for file in $files; do
...
@@ -72,7 +74,7 @@ for file in $files; do
continue
continue
fi
fi
if
ansible-vault decrypt
${
file
}
--vault-password-file
./
.git/
hooks/getPassword.sh
>
/dev/null 2>&1
;
then
if
ansible-vault decrypt
${
file
}
--
vault-password-file ./
$
hooks
Path
/
getPassword.sh
>
/
dev/null
2
>&
1
;
then
echo
-
ne
"
${
green
}
✓
${
clear
}
"
echo
-
ne
"
${
green
}
✓
${
clear
}
"
else
else
echo
-
ne
"
${
red
}
🮽
${
clear
}
"
echo
-
ne
"
${
red
}
🮽
${
clear
}
"
...
...
This diff is collapsed.
Click to expand it.
pre-commit
View file @
9b65faad
...
@@ -12,6 +12,9 @@ clear='\033[0m'
...
@@ -12,6 +12,9 @@ clear='\033[0m'
patternsFile
=
.files-for-encryption
patternsFile
=
.files-for-encryption
# get the used hooks path and remove the trailing slash
hooksPath
=
$((
git config core.hooksPath
||
echo
".git/hooks/"
)
|
sed
's:/*$::'
)
VERBOSE
=
false
VERBOSE
=
false
# Function to print verbose messages
# Function to print verbose messages
verbose
()
{
verbose
()
{
...
@@ -21,7 +24,7 @@ verbose() {
...
@@ -21,7 +24,7 @@ verbose() {
}
}
activate
()
{
activate
()
{
.
.git/
hooks/.venv/bin/activate
.
$
hooks
Path
/
.venv/bin/activate
}
}
# check for "$ANSIBLE_VAULT"
# check for "$ANSIBLE_VAULT"
...
@@ -47,7 +50,7 @@ patterns=$(<$patternsFile)
...
@@ -47,7 +50,7 @@ patterns=$(<$patternsFile)
activate
activate
# match the files for encryption
# match the files for encryption
files
=
$(
python
.git/
hooks/get-matched-files-for-encryption.py
$patternsFile
.
)
files
=
$(
python
$
hooks
Path
/get-matched-files-for-encryption.py
$patternsFile
.
)
echo
-
e
"
${
blue
}
files to encrypt:
${
clear
}
"
echo
-
e
"
${
blue
}
files to encrypt:
${
clear
}
"
for
file
in
$files
;
do
for
file
in
$files
;
do
...
@@ -74,7 +77,7 @@ for file in $files; do
...
@@ -74,7 +77,7 @@ for file in $files; do
continue
continue
fi
fi
if
ansible-vault encrypt
${
file
}
--vault-password-file
./
.git/
hooks/getPassword.sh
>
/dev/null 2>&1
;
then
if
ansible-vault encrypt
${
file
}
--
vault-password-file ./
$
hooks
Path
/
getPassword.sh
>
/
dev/null
2
>&
1
;
then
echo
-
ne
"
${
green
}
✓
${
clear
}
"
echo
-
ne
"
${
green
}
✓
${
clear
}
"
# only add the encrypted file if it was already staged
# only add the encrypted file if it was already staged
...
...
This diff is collapsed.
Click to expand it.