Skip to content

k-ader/ansible-configuration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible environment setup

Ansible is a python product, so let's operate with it as any python programm.

Requirements

  • Any os with bash, zsh or other *nix-style command promt
  • python 3.10.x
  • virtualenv using wanted!
  • ansible-core above 2.13.0 but lower 2.13.6

If you are installing software not to virtualenv or --user it's your own risk to broke security or working environment using highest privileges

Ansible dependencies configuration

Make sure you have uninstalled all other versions to avoid broken dependencies (better option is uuse virtualenv!)

Prepare local env to running ansible

Setting env

pip install --upgrade pip virtualenv
python -m virtualenv $HOME/ansible-core2.13
source $HOME/ansible-core2.13/bin/activate
pip install --upgrade -r requirements.txt
ansible-galaxy install -r requirements.yml

Molecule preparation

  • Complete meta/main.yml from your role with template from templates_role/meta.yml
  • Add requirements.yml to root of your role with all depenencies using as template file templates_role/requirements.yml if you have any dependencies for your role

Make sure you have same linter configs in root of you role as all other

  • copy from templates_linter to your role
  • check your role with commands:
yamllint ./ ;\
ansible-lint ./ -v

fix all errors before continue

Run in root folder of your role

molecule init scenario --role-name YOUR_ROLE_NAME --driver-name ec2


#### Running molecule

Test your molecule config by
```shell
 molecule create

Run tests by

molecule test --destroy=never -- -b -e ANSIBLE_VAR=ANSIBLE_VALUE

Where after -- going ansible arguments passing from molecule to your playbook:

  • become -b
  • any additional variables for role -e ANSIBLE_VAR=ANSIBLE_VALUE

NB!!! Don't forget execute destroy after end of testing

molecule destroy

About

Ansible Configuration. Make things the same

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published