Skip to content

Instantly share code, notes, and snippets.

@scottking2
Created February 17, 2017 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottking2/d82f66260a57562e92274a04fe643dce to your computer and use it in GitHub Desktop.
Save scottking2/d82f66260a57562e92274a04fe643dce to your computer and use it in GitHub Desktop.
python execution module to create security.list for apt security updates
# -*- 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