1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-03-09 23:38:54 +00:00

Ansible 2.7.0 support

This commit is contained in:
debojitkakoti 2018-11-30 12:45:45 +05:30
parent 8953f04daf
commit be1b80520e
2 changed files with 8 additions and 7 deletions

View file

@ -11,7 +11,7 @@ RUN echo "root:P@ssw0rd@123" | chpasswd
RUN apt-get update && \
apt-get install python-setuptools python-dev build-essential -y && \
easy_install pip && \
pip install ansible && \
pip install ansible==2.7.0 && \
pip install pyOpenSSL==16.2.0
# -----------------------------------------------------------

View file

@ -7,7 +7,7 @@ from collections import namedtuple
from ansible.cli import CLI
from ansible.parsing.dataloader import DataLoader
from ansible.inventory import Inventory
from ansible.inventory.manager import InventoryManager
from ansible.executor.playbook_executor import PlaybookExecutor
from ansible.playbook import Playbook
@ -15,7 +15,7 @@ from ansible.playbook.block import Block
from ansible.playbook.play_context import PlayContext
from ansible.utils.vars import load_extra_vars
from ansible.utils.vars import load_options_vars
from ansible.vars import VariableManager
from ansible.vars.manager import VariableManager
import optparse
@ -28,11 +28,12 @@ def host_vars():
parser.add_argument('--inventory_file', help='Inventory Filename', required=True)
parser.add_argument('--host_name', help='Host or Group name', required=True)
args= parser.parse_args()
variable_manager = VariableManager()
loader = DataLoader()
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=args.inventory_file)
inventory = InventoryManager(loader=loader, sources=args.inventory_file)
variable_manager = VariableManager(loader=loader, inventory=inventory)
# inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=args.inventory_file)
result = None
if args.host_name in variable_manager.__getstate__()['host_vars_files']:
result = variable_manager.__getstate__()['host_vars_files'][args.host_name]
@ -226,7 +227,7 @@ def list_tags():
# variable_manager.options_vars = load_options_vars(options)
# create the inventory, and filter it based on the subset specified (if any)
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=inventory_path)
inventory = InventoryManager(loader=loader, sources=inventory_path)
variable_manager.set_inventory(inventory)
# (which is not returned in list_hosts()) is taken into account for