Skip to content

Commit

Permalink
Merge pull request #3 from hellofresh/patch/python3
Browse files Browse the repository at this point in the history
Fix for python3
  • Loading branch information
Anton Ustyuzhanin authored Jul 30, 2019
2 parents 56ff49d + cc4a4fd commit cc3903b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 39 deletions.
9 changes: 0 additions & 9 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ platforms:
image : centos:7
platform : centos

- name : alpine-v2.2
provisioner :
ansible_playbook_bin : "$(avm path v2.2)ansible-playbook"
driver_config :
image : alpine:3.4
platform : alpine
provision_command :
- apk add python shadow
- mkdir -p /opt

suites:
- name : group
Expand Down
13 changes: 0 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,42 @@ services:
- docker

env:
- KITCHEN_TEST="advanced-alpine"
- KITCHEN_TEST="advanced-centos7"
- KITCHEN_TEST="advanced-ubuntu1404"
- KITCHEN_TEST="advanced-ubuntu1604"
- KITCHEN_TEST="extra-advanced-alpine"
- KITCHEN_TEST="extra-advanced-centos7"
- KITCHEN_TEST="extra-advanced-ubuntu1404"
- KITCHEN_TEST="extra-advanced-ubuntu1604"
- KITCHEN_TEST="extra-simple-alpine"
- KITCHEN_TEST="extra-simple-centos7"
- KITCHEN_TEST="extra-simple-ubuntu1404"
- KITCHEN_TEST="extra-simple-ubuntu1604"
- KITCHEN_TEST="extra-team-alpine"
- KITCHEN_TEST="extra-team-centos7"
- KITCHEN_TEST="extra-team-ubuntu1404"
- KITCHEN_TEST="extra-team-ubuntu1604"
- KITCHEN_TEST="group-alpine"
- KITCHEN_TEST="group-centos7"
- KITCHEN_TEST="group-ubuntu1404"
- KITCHEN_TEST="group-ubuntu1604"
- KITCHEN_TEST="include-vars-dir-alpine"
- KITCHEN_TEST="include-vars-dir-centos7"
- KITCHEN_TEST="include-vars-dir-ubuntu1404"
- KITCHEN_TEST="include-vars-dir-ubuntu1604"
- KITCHEN_TEST="include-vars-file-alpine"
- KITCHEN_TEST="include-vars-file-centos7"
- KITCHEN_TEST="include-vars-file-ubuntu1404"
- KITCHEN_TEST="include-vars-file-ubuntu1604"
- KITCHEN_TEST="multi-source-files-alpine"
- KITCHEN_TEST="multi-source-files-centos7"
- KITCHEN_TEST="multi-source-files-ubuntu1404"
- KITCHEN_TEST="multi-source-files-ubuntu1604"
- KITCHEN_TEST="selected-users-alpine"
- KITCHEN_TEST="selected-users-centos7"
- KITCHEN_TEST="selected-users-ubuntu1404"
- KITCHEN_TEST="selected-users-ubuntu1604"
- KITCHEN_TEST="simple-alpine"
- KITCHEN_TEST="simple-centos7"
- KITCHEN_TEST="simple-ubuntu1404"
- KITCHEN_TEST="simple-ubuntu1604"
- KITCHEN_TEST="source-databag-alpine"
- KITCHEN_TEST="source-databag-centos7"
- KITCHEN_TEST="source-databag-ubuntu1404"
- KITCHEN_TEST="source-databag-ubuntu1604"
- KITCHEN_TEST="source-files-alpine"
- KITCHEN_TEST="source-files-centos7"
- KITCHEN_TEST="source-files-ubuntu1404"
- KITCHEN_TEST="source-files-ubuntu1604"
- KITCHEN_TEST="team-alpine"
- KITCHEN_TEST="team-centos7"
- KITCHEN_TEST="team-ubuntu1404"
- KITCHEN_TEST="team-ubuntu1604"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ source 'https://rubygems.org'
group :development do
gem 'test-kitchen'
gem 'kitchen-ansiblepush'
gem 'kitchen-docker', :git => 'https://github.com/ahelal/kitchen-docker.git', :branch => 'feature/alpine'
gem 'kitchen-docker'
gem 'kitchen-verifier-serverspec'
gem 'net-ssh'
gem 'serverspec'
end
end
14 changes: 4 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
GIT
remote: https://github.com/ahelal/kitchen-docker.git
revision: 12552cc580393108e67ba9f933a8730b3ab0187f
branch: feature/alpine
specs:
kitchen-docker (2.6.1.pre)
test-kitchen (>= 1.0.0)

GEM
remote: https://rubygems.org/
specs:
artifactory (2.5.1)
diff-lcs (1.2.5)
kitchen-ansiblepush (0.5.1)
test-kitchen
kitchen-docker (2.9.0)
test-kitchen (>= 1.0.0)
kitchen-verifier-serverspec (0.6.2)
net-ssh (~> 3)
test-kitchen (~> 1.4)
Expand Down Expand Up @@ -73,11 +67,11 @@ PLATFORMS

DEPENDENCIES
kitchen-ansiblepush
kitchen-docker!
kitchen-docker
kitchen-verifier-serverspec
net-ssh
serverspec
test-kitchen

BUNDLED WITH
1.13.6
1.16.6
2 changes: 1 addition & 1 deletion library/load_user_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def convert_chef_user_data_bag(self, data):
new_data.update({ansible_key: data_bag_item_value})

if self.extract_extra_keys:
for key, value in data.iteritems():
for key, value in list(data.items()):
new_data.update({key: value})
# Check for an action
chef_action = new_data.get("state", False)
Expand Down
19 changes: 15 additions & 4 deletions library/usersdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
'keys']


def merge_dicts(*dict_args):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
"""
result = {}
for dictionary in dict_args:
result.update(dictionary)
return result


class UsersDB(object):
def __init__(self, module):
self.module = module
Expand Down Expand Up @@ -110,7 +121,7 @@ def _merge_user(self, user_name, user_server):
user_status = False

# Merge User and Server ( Server has precedence in this case )
merged_user = dict(user_definition.items() + user_server.items())
merged_user = merge_dicts(user_definition.items(), user_server.items())

if user_status:
merged_user.update({"state": "absent"})
Expand All @@ -130,7 +141,7 @@ def _merge_user(self, user_name, user_server):

def expand_servers_extra(self, user_name):
## Add self.extra_server_data
extra_user_item = filter(lambda exta_user: exta_user['name'] == user_name, self.extra_users_data)
extra_user_item = list(filter(lambda exta_user: exta_user['name'] == user_name, self.extra_users_data))
# not empty than add
if extra_user_item != []:
# We make a good assumption that we only get one item :( which is somehow true but probably need to check it
Expand Down Expand Up @@ -203,7 +214,7 @@ def expand_users(self):
:return:
"""

for username, user_options in self.users_db.iteritems():
for username, user_options in list(self.users_db.items()):

# Check if usermanage_selected_users is set, and exclude users
if self.selected_users:
Expand All @@ -215,7 +226,7 @@ def expand_users(self):
# 1- Check for extra keys that dont translate to ansible user module
if self.extract_extra_keys:
extra_user_data = None
for dic_key in user_options.keys():
for dic_key in list(user_options.keys()):
if dic_key not in USERVALUES:
# Add user and state
if not extra_user_data:
Expand Down

0 comments on commit cc3903b

Please sign in to comment.