Created
February 17, 2017 16:32
-
-
Save scottking2/d82f66260a57562e92274a04fe643dce to your computer and use it in GitHub Desktop.
python execution module to create security.list for apt security updates
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
# -*- coding: utf-8 -*- | |
# Import python libs | |
import os | |
import copy | |
import shutil | |
from shutil import copyfile | |
#Import salt libs | |
import salt.utils | |
import salt.utils.itertools | |
if os.path.exists('/etc/apt/securitytest.list'): | |
print 'already exists' | |
else: | |
security_words = ['security'] | |
with open('/etc/apt/sources.list') as oldfile, open('/etc/apt/securitytest.list', 'w') as newfile: | |
for line in oldfile: | |
if any (security_word in line for security_word in security_words): | |
newfile.write(line) | |
if __grains__.get['os'] == 'Ubuntu': | |
print 'it worked' | |
else: | |
print 'salt utils didn\'t work.' | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment