25
25
import os
26
26
import shutil
27
27
28
+ from aminator .plugins .provisioner .base import BaseProvisionerPlugin
28
29
from aminator .config import conf_action
29
- from aminator .plugins .provisioner .linux import BaseProvisionerPlugin
30
- from aminator .util .linux import command , Chroot
30
+ from aminator .util .linux import command
31
31
32
32
__all__ = ('AnsibleProvisionerPlugin' ,)
33
33
log = logging .getLogger (__name__ )
@@ -49,40 +49,6 @@ def add_plugin_args(self):
49
49
ansible_config .add_argument ('-ev' , '--extra-vars' , dest = 'extravars' , help = 'A set of additional key=value variables to be used in the playbook' ,
50
50
action = conf_action (self ._config .plugins [self .full_name ]))
51
51
52
-
53
- def provision (self ):
54
- """ The main provisioning flow """
55
-
56
- context = self ._config .context
57
-
58
- log .debug ('Pre chroot command block' )
59
- self ._pre_chroot_block ()
60
-
61
- log .debug ('Entering chroot at {0}' .format (self ._mountpoint ))
62
-
63
- with Chroot (self ._mountpoint ):
64
- log .debug ('Inside chroot' )
65
-
66
- result = self ._write_local_inventory ()
67
- if not result :
68
- log .critical ('Could not write local inventory file: {0.std_err}' .format (result .result ))
69
- return False
70
-
71
- result = self ._provision_package ()
72
- if not result .success :
73
- log .critical ('Installation of {0} failed: {1.std_err}' .format (context .package .arg , result .result ))
74
- return False
75
- self ._store_package_metadata ()
76
-
77
- self ._ansible_cleanup ()
78
-
79
- log .debug ('Exited chroot' )
80
-
81
- log .debug ('Post chroot command block' )
82
- self ._post_chroot_block ()
83
-
84
- log .info ('Provisioning succeeded!' )
85
- return True
86
52
87
53
88
54
def _write_local_inventory (self ):
@@ -136,6 +102,11 @@ def _copy_playbooks(self):
136
102
def _provision_package (self ):
137
103
""" Sets up the command to get Ansible to run """
138
104
105
+ result = self ._write_local_inventory ()
106
+ if not result :
107
+ log .critical ('Could not write local inventory file: {0.std_err}' .format (result .result ))
108
+ return False
109
+
139
110
context = self ._config .context
140
111
config = self ._config .plugins [self .full_name ]
141
112
extra_vars = config .get ('extravars' , '' )
@@ -148,6 +119,8 @@ def _provision_package(self):
148
119
def _store_package_metadata (self ):
149
120
""" Store metadata about the AMI created """
150
121
122
+ self ._ansible_cleanup ()
123
+
151
124
context = self ._config .context
152
125
config = self ._config .plugins [self .full_name ]
153
126
metadata = {}
0 commit comments