diff options
author | B Stack <bgstack15@gmail.com> | 2016-10-03 12:22:55 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2016-10-03 12:22:55 -0400 |
commit | 49aef0810a4c953f3aa34af95b00ca9dd9b5f5d0 (patch) | |
tree | 386002ee8e1f7d7a519cf76848cd768d1f0aabcb | |
parent | added script that brings in the .git directory to the localized project folder (diff) | |
download | ansible01-49aef0810a4c953f3aa34af95b00ca9dd9b5f5d0.tar.gz ansible01-49aef0810a4c953f3aa34af95b00ca9dd9b5f5d0.tar.bz2 ansible01-49aef0810a4c953f3aa34af95b00ca9dd9b5f5d0.zip |
Fixed filename export process in scrub.py
-rw-r--r-- | company/ad-templates/sssd.conf.CentOS | 2 | ||||
-rw-r--r-- | company/ad-templates/sssd.conf.FreeBSD | 2 | ||||
-rw-r--r-- | company/ad-templates/sssd.conf.Ubuntu | 2 | ||||
-rw-r--r-- | company/ad-vars/FreeBSD.yml | 2 | ||||
-rw-r--r-- | company/fail2ban-files/filter.d/20_example-blns.filter (renamed from company/fail2ban-files/filter.d/20_bju-blns.filter) | 0 | ||||
-rw-r--r-- | company/fail2ban-files/filter.d/30_example-max3.filter (renamed from company/fail2ban-files/filter.d/30_bju-max3.filter) | 0 | ||||
-rw-r--r-- | company/fail2ban-files/jail.d/20_example-blns.jail (renamed from company/fail2ban-files/jail.d/20_bju-blns.jail) | 0 | ||||
-rw-r--r-- | company/fail2ban-files/jail.d/30_example-max3.jail (renamed from company/fail2ban-files/jail.d/30_bju-max3.jail) | 0 | ||||
-rw-r--r-- | company/pubkeys/bgstack15.pubkeys (renamed from company/pubkeys/bgirton.pubkeys) | 0 | ||||
-rw-r--r-- | company/pubkeys/user16.pubkey (renamed from company/pubkeys/lcroce.pubkey) | 0 | ||||
-rw-r--r-- | company/sudo-files/40_BGIRTON | 2 | ||||
-rw-r--r-- | company/sudo-files/40_BGSTACK15 | 2 | ||||
-rwxr-xr-x | inc/localize_git.sh | 2 | ||||
-rwxr-xr-x | inc/scrub.py | 18 | ||||
-rw-r--r-- | inc/scrub.txt | 10 | ||||
-rw-r--r-- | roles/sudo/tests/test.yml | 4 | ||||
-rw-r--r-- | test.yml | 4 |
17 files changed, 31 insertions, 19 deletions
diff --git a/company/ad-templates/sssd.conf.CentOS b/company/ad-templates/sssd.conf.CentOS index dafb287..e6ce4b4 100644 --- a/company/ad-templates/sssd.conf.CentOS +++ b/company/ad-templates/sssd.conf.CentOS @@ -36,7 +36,7 @@ use_fully_qualified_names = False fallback_homedir = /home/%d/%u access_provider = ad ad_access_filter = (&(memberOf=CN=Linux-Server-Access_grp,OU=Linux-Access,OU=Accounts-Groups,DC=example,DC=com)(unixHomeDirectory=*)) -simple_allow_users = bgstack15, bgstack15, user16, user16 +simple_allow_users = Bgstack15, bgstack15, User16, user16 case_sensitive = true ad_gpo_access_control = disabled [autofs] diff --git a/company/ad-templates/sssd.conf.FreeBSD b/company/ad-templates/sssd.conf.FreeBSD index 9add0ed..2be88fe 100644 --- a/company/ad-templates/sssd.conf.FreeBSD +++ b/company/ad-templates/sssd.conf.FreeBSD @@ -36,6 +36,6 @@ use_fully_qualified_names = False fallback_homedir = /home/%d/%u access_provider = ad ad_access_filter = (&(memberOf=CN=Linux-Server-Access_grp,OU=Linux-Access,OU=Accounts-Groups,DC=example,DC=com)(unixHomeDirectory=*)) -simple_allow_users = bgstack15, bgstack15, user16, user16 +simple_allow_users = Bgstack15, bgstack15, User16, user16 case_sensitive = true ad_gpo_access_control = disabled diff --git a/company/ad-templates/sssd.conf.Ubuntu b/company/ad-templates/sssd.conf.Ubuntu index 7b7dae3..c47a466 100644 --- a/company/ad-templates/sssd.conf.Ubuntu +++ b/company/ad-templates/sssd.conf.Ubuntu @@ -36,7 +36,7 @@ use_fully_qualified_names = False fallback_homedir = /home/%d/%u access_provider = ad ad_access_filter = (&(memberOf=CN=Linux-Server-Access_grp,OU=Linux-Access,OU=Accounts-Groups,DC=example,DC=com)(unixHomeDirectory=*)) -simple_allow_users = bgstack15, bgstack15, user16, user16 +simple_allow_users = Bgstack15, bgstack15, User16, user16 case_sensitive = true ad_gpo_access_control = disabled [autofs] diff --git a/company/ad-vars/FreeBSD.yml b/company/ad-vars/FreeBSD.yml index 77e2a9c..7777099 100644 --- a/company/ad-vars/FreeBSD.yml +++ b/company/ad-vars/FreeBSD.yml @@ -1,4 +1,4 @@ --- sssd_dir: /usr/local/etc/sssd ad_access_filter: (&(memberOf=CN=Linux-Server-Access_grp,OU=Linux-Access,OU=Accounts-Groups,DC=example,DC=com)(unixHomeDirectory=*)) -simple_allow_users: bgstack15, bgstack15, bgstack15-local +simple_allow_users: Bgstack15, bgstack15, bgstack15-local diff --git a/company/fail2ban-files/filter.d/20_bju-blns.filter b/company/fail2ban-files/filter.d/20_example-blns.filter index c39cefa..c39cefa 100644 --- a/company/fail2ban-files/filter.d/20_bju-blns.filter +++ b/company/fail2ban-files/filter.d/20_example-blns.filter diff --git a/company/fail2ban-files/filter.d/30_bju-max3.filter b/company/fail2ban-files/filter.d/30_example-max3.filter index af692af..af692af 100644 --- a/company/fail2ban-files/filter.d/30_bju-max3.filter +++ b/company/fail2ban-files/filter.d/30_example-max3.filter diff --git a/company/fail2ban-files/jail.d/20_bju-blns.jail b/company/fail2ban-files/jail.d/20_example-blns.jail index eb1d1c9..eb1d1c9 100644 --- a/company/fail2ban-files/jail.d/20_bju-blns.jail +++ b/company/fail2ban-files/jail.d/20_example-blns.jail diff --git a/company/fail2ban-files/jail.d/30_bju-max3.jail b/company/fail2ban-files/jail.d/30_example-max3.jail index 6ca7781..6ca7781 100644 --- a/company/fail2ban-files/jail.d/30_bju-max3.jail +++ b/company/fail2ban-files/jail.d/30_example-max3.jail diff --git a/company/pubkeys/bgirton.pubkeys b/company/pubkeys/bgstack15.pubkeys index 85abeb0..85abeb0 100644 --- a/company/pubkeys/bgirton.pubkeys +++ b/company/pubkeys/bgstack15.pubkeys diff --git a/company/pubkeys/lcroce.pubkey b/company/pubkeys/user16.pubkey index 8ed442d..8ed442d 100644 --- a/company/pubkeys/lcroce.pubkey +++ b/company/pubkeys/user16.pubkey diff --git a/company/sudo-files/40_BGIRTON b/company/sudo-files/40_BGIRTON deleted file mode 100644 index 5e27584..0000000 --- a/company/sudo-files/40_BGIRTON +++ /dev/null @@ -1,2 +0,0 @@ -User_Alias bgstack15 = bgstack15, bgstack15, bgstack15-local -bgstack15 ALL=(ALL) NOPASSWD: ALL diff --git a/company/sudo-files/40_BGSTACK15 b/company/sudo-files/40_BGSTACK15 new file mode 100644 index 0000000..efd3f9c --- /dev/null +++ b/company/sudo-files/40_BGSTACK15 @@ -0,0 +1,2 @@ +User_Alias BGSTACK15 = Bgstack15, bgstack15, bgstack15-local +BGSTACK15 ALL=(ALL) NOPASSWD: ALL diff --git a/inc/localize_git.sh b/inc/localize_git.sh index 7dd2381..99ae4af 100755 --- a/inc/localize_git.sh +++ b/inc/localize_git.sh @@ -1,2 +1,2 @@ #!/bin/sh -\cp -pRf /home/bgstack15/ansible.clean/.git /etc/ansible +\cp -pRf /home/work/ansible.clean/.git /etc/ansible diff --git a/inc/scrub.py b/inc/scrub.py index a0e9c70..aafc295 100755 --- a/inc/scrub.py +++ b/inc/scrub.py @@ -6,7 +6,8 @@ # Title: Script that Simultaneously Copies and Scrubs a Directory # Purpose: Prepare projects for publication by removing private information like usernames and hostnames # Package: Various -# History: +# History: +# 2016-10-03 working on batch rename files # Usage: # Store this file with any package that gets published. Adjust scrub.txt in local directory. # # First line: source directory Second line: target directory. WILL BE OVERWRITTEN! @@ -21,16 +22,17 @@ # http://stackoverflow.com/questions/6584871/remove-last-character-if-its-a-backslash/6584893#6584893 # http://stackoverflow.com/questions/2212643/python-recursive-folder-read/2212728#2212728 # parallel lists: http://stackoverflow.com/questions/1663807/how-can-i-iterate-through-two-lists-in-parallel-in-python +# file renames http://stackoverflow.com/questions/225735/batch-renaming-of-files-in-a-directory/7917798#7917798 # Improve: # Add option to specify scrub file # Add exclude option to scrub file, such as .git and so on # Accept CLI options like source, destination, even exclusions? -# Also change filenames +# Add flag for performing file renames as well, or file renames only import re, shlex, os, sys, shutil from pathlib import Path # scrubpy version -scrubpyversion = "2016-09-29b" +scrubpyversion = "2016-10-03a" # Define functions @@ -107,3 +109,13 @@ for rootfolder, subdirs, files in os.walk(thisdir): data = data.replace(oldword,newword) changed = data target.write(changed) + +# Execute file renames +# Used "file renames" reference, as well as the structure of directory traversal used earlier, which was from a different source. +for rootfolder, subdirs, files in os.walk(newdir): + for filename in files: + oldpath = os.path.join(rootfolder, filename) + for oldword, newword in zip(oldstrings, newstrings): + if oldword in oldpath: + #print("oldword=" + oldword + "\toldpath=" + oldpath) + os.rename(oldpath, oldpath.replace(oldword,newword)) diff --git a/inc/scrub.txt b/inc/scrub.txt index 13922bb..160433e 100644 --- a/inc/scrub.txt +++ b/inc/scrub.txt @@ -1,12 +1,12 @@ # First line: source directory Second line: target directory. WILL BE OVERWRITTEN! /etc/ansible -/home/bgstack15/ansible.clean +/home/work/ansible.clean # Rest of the lines are "OLD WORD" "NEW WORD" +BGSTACK15 BGSTACK15 +Bgstack15 Bgstack15 bgstack15 bgstack15 -bgstack15 bgstack15 -bgstack15 bgstack15 -user16 user16 -user16 user16 +USER16 USER16 +User16 User16 user16 user16 example example EXAMPLE EXAMPLE diff --git a/roles/sudo/tests/test.yml b/roles/sudo/tests/test.yml index e15f798..f170ffd 100644 --- a/roles/sudo/tests/test.yml +++ b/roles/sudo/tests/test.yml @@ -6,7 +6,7 @@ - sudo vars: sudo_strings: - - { priority: 42, exists: 'false', name: 'admins-do-all', content: 'User_Alias ADMINS = bgstack15, bgstack15, user16, user16' } + - { priority: 42, exists: 'false', name: 'admins-do-all', content: 'User_Alias ADMINS = Bgstack15, bgstack15, user16, User16' } - { priority: 43, exists: false, name: 'a', content: "ADMINS ALL=(ALL) ALL" } sudo_files: - - { exists: 'false', file: '../../../company/sudo-files/40_bgstack15' } + - { exists: 'false', file: '../../../company/sudo-files/40_BGSTACK15' } @@ -6,7 +6,7 @@ - sudo vars: sudo_strings: - - { priority: 42, exists: 'false', name: 'admins-do-all', content: 'User_Alias ADMINS = bgstack15, bgstack15, user16, user16' } + - { priority: 42, exists: 'false', name: 'admins-do-all', content: 'User_Alias ADMINS = Bgstack15, bgstack15, user16, User16' } - { priority: 43, exists: false, name: 'a', content: "ADMINS ALL=(ALL) ALL" } sudo_files: - - { exists: 'false', file: '../../../company/sudo-files/40_bgstack15' } + - { exists: 'false', file: '../../../company/sudo-files/40_BGSTACK15' } |