我想在以下route.py中执行ansible脚本
我想在以下route.py部分中执行ansible脚本
@app.route("/VLANs", methods=['GET', 'POST'])
def VLANs():
form = VLANsForm()
if form.validate_on_submit():
{{{ ansible script here }}}
flash('Your VLAN has been created!', 'success')
return redirect(url_for('home'))
return render_template('VLANs.html', title='Create VLAN',
form=form, legend='Create VLAN')
最终,我想将不断变化的变量解析为脚本。
class VLANsForm(FlaskForm):
user_name = StringField('Enter Cisco ISE username', validators=[DataRequired()])
user_pass = PasswordField('Enter Cisco ISE password', validators=[DataRequired()])
vlan_number = StringField('Enter VLAN number', validators=[DataRequired()])
vlan_desc = StringField('Enter VLAN description', validators=[DataRequired()])
vlan_state = SelectField('Add or Remove VLANs?', choices=[('add', 'add'), ('remove', 'remove')])
admin_state = SelectField('Admin state, Up or Down?', choices=[('up', 'up'), ('down', 'down')])
device_ip = TextAreaField('Copy and Paste IPs (comma delimited)', validators=[DataRequired()])
submit = SubmitField('Create VLANs')