How to create Ansible Module | Hands on Demo and Code

preview_player
Показать описание
In this session, we will discuss how we can create our own custom modules in Ansible.

So this ansible module , will be used to install applications, execute commands and operations on the hosts which are a part of your host group.

Join this channel to get access to perks:

⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for 6 months and I love it!

🍀 If you wish to support me please choose the links below:

AWS Solutions Architect Associate Certification 2021 Playlist:

Please follow in the links below to stay updated: 🙌

Disclaimer: The content provided in the channel are not affiliated in any way to the organization. We provide information here on the channel based on the knowledge we have on the topic. We advise our viewers to please do their own research and read more about them from the source provided by the organization to get a better outlook on the topic that has been covered.
These videos are just to provide you a platform to learn, and there can be mistakes and we are always trying to improve based on your feedback. we recommend viewers to have an open mind. Please support the channel to get more content like these in the future.

#Ansible #AnsibleVariable #StaySafe
Рекомендации по теме
Комментарии
Автор

Very nicely explained, buddy. Enjoyed and learned a lot. Thank you 😊

kennyaulakh
Автор

Nice to see Ansible series.. But wanting for some AWS services like Redshift, Cognito, Lambda+SES..Migration etc..

Vishal-wrcc
Автор

@31:26 Oh, just realized your coding style is way different than waht I'm used to. In this part, 'd whip up a decorator to keep the code dynamic.

import base64

def base64_operation(operation):
def decorator(func):
def wrapper(message):
message_byte = message.encode('ascii')
processed_byte = func(message_byte)
return {
'original_message': message,
f'{operation}_message': procesed_byte.decode('ascii'),
'message': f'Your data is {operation}d'.
}
return wrapper
return decorator

@base64_operation('encode')
def encode_data(message_byte):
return

@base64_operation('decode')
def decode_data(message_byte):
return

operations = {
'encode': encode_data,
'decode': decode_data
}

module_params_type = module.params['type'].lower()
message = module.params['name']

result.update(operations.get(module_params_type, lambda x: {
'message': 'Invalid operation type'
})(message))

luciusstark
Автор

Which is the terminal console you are using?

anoopk
Автор

@25:08 Next time, roll with a dict. It's slicker and more Pythonic.

module_params_type = module.params['type'].lower()
status = {'encode': False, 'decode': False}

status[module_params_type] = module_params_type in status

encode_status = status['encode']
decode_status = status['decode']

luciusstark
welcome to shbcf.ru