Sunday, July 31, 2022
Information Technology Manager - How to IT the right way
But far too often, I've seen horribly run IT departments. They focus on things that don't support company goals, they neglect things that enhance performance and security. They can even burn out IT employees, pushing them out the door, losing productivity since they now have to spend time training a new employee.
Here are some tips when it comes to running your IT department.
Organizational leaders must trust and empower their IT manager.
This is non-negotiable. This is not saying that you should blindly agree with everything they say. But you should give them direction, give them a budget, and get the hell out of the way.
A good IT manager should have a diverse background, hopefully someone with previous management experience. You should respect them and they should be able to effectively translate IT-speak to terms that management understands.
But most of all, a good IT manager will understand company goals, author policies to support those goals, and have a plan to leverage IT to support an organization's objectives.
What not to do? If you oversee the IT manager, don't get into the weeds and do their job for them (aka micromanage). Don't pluck IT personnel for special taskings (ex. manual labor help) without first consulting with the IT manager and understanding what impact that may have on IT operations. Don't give them the solution; instead, give them the problem and let IT give you the solution.
What can an IT manager do for you?
An IT manager can do several things:
1. It starts with understanding company objectives, culture, and what they may be inheriting.
2. They should author policies that align with company objectives.
3. If IT is not fully supporting the organization as you'd like, they should present several courses of action and what those actions will cost.
4. They should present a roadmap on how to get to an ideal state.
5. They should be well informed and ready to present senior leaders with information such as: security posture, operational performance, ongoing project statuses, upcoming maintenances and impacts, accomplishments as well as shortcomings.
6. IT managers should implement programs such as: monitoring, security (recommend you have a separate security manager that serves as a 'checks' for IT), maintenance, asset management, training, and systems lifecycle management.
7. IT managers should play an active role in streamlining operations.
8. And last but not least, their people should want to work for them, not the other way around. Managers should challenge, but not overwhelm their employees. They should praise in public and punish in private. Managers should complain up, not down.
Feedback welcome.
Wednesday, May 11, 2022
Ansible - Extract Dictionary Values When Nested Inside A List - Python solution
Ansible has some great built-in filters that can be found here. Two filters worth noting is items2dict and dict2items. These two filters enable you to either convert a list to a dictionary format, or a dictionary to a list format.
There is one problem though. What if you have a dictionary that is embedded into a list and want to extract dictionary values into a list? This is where it gets complicated.
OR, you can take advantage of the Ansible custom filter option and create your own filter.
#!/usr/bin/python3
#
# itemdict_to_item.py
# This iterates through a list of dictionaries,
# extracts a dictionary value and combines
# the values into a list.
#
# Example:
# my_list[{'my_key': 'value1'},{'my_key': 'value2'}]
#
# Apply the filter as so:
# {{ my_list | itemdict_to_item('my_key') }}
#
# Returned result:
# ['value1', 'value2']
#
class FilterModule(object):
def filters(self):
return {'itemdict_to_item': self.extracted_values}
def extracted_values(self, outer_list, passed_key):
# Create a blank list that will hold the extracted
# values.
ret_list = []
# Loop through the list. If the key exists in the
# nested dictionary, append its paired value to
# ret_list
for nested_dict in outer_list:
if passed_key in nested_dict:
ret_list.append(nested_dict[passed_key])
return ret_list
You'll need to create a directory called filter_plugins within the same directory as the playbook you're running. Your Python script will go in the filter_plugins directory. The file name is irrelevant, just be sure it ends with .py
[dan@localhost playbooks]$ ls
my_playbook.yml filter_plugins
[dan@localhost playbooks]$ ls filter_plugins/
my_custom_filter.py
Finally, I use it in an Ansible play. I want to create a list of files that are in a directory.
- name: Get files in directory
ansible.builtin.find:
paths: /some/directory
register: search_results
- name: Set Fact
ansible.builtin.set_fact:
search_list: "{{ search_results['files'] | itemdict_to_item('path') }}"