我正在尝试通过将变量嵌套在另一个变量中来创建一些更有效的任务来升级网络设备,以便可以通过单个任务而不是每个模型的任务提取适当的信息,事实证明这是20多个任务。我正在使用juniper_junos_facts模块提取模型信息,在这种情况下,junos.model的输出是srx550,然后利用另一个变量内部的那个变量来形成model.srx550.path。
vars
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Camera : MonoBehaviour
{
public Transform tank;
private Transform target;
public float distance = 5.0f;
public float xSpeed = 250.0f;
public float ySpeed = 120.0f;
public float yMinLimit = -20.0f;
public float yMaxLimit = 80.0f;
private float x;
private float y;
public float heightOffset = 0;
void Awake()
{
Vector3 angles = transform.eulerAngles;
x = angles.x;
y = angles.y;
GameObject newTarget = new GameObject("target");
target = newTarget.transform;
FindObjectOfType<TankGunController>().target = target;
}
void LateUpdate()
{
if (tank != null)
{
x += (float)(Input.GetAxis ("Mouse X") * xSpeed * 0.02f);
y -= (float)(Input.GetAxis ("Mouse Y") * ySpeed * 0.02f);
y = ClampAngle (y, yMinLimit, yMaxLimit);
Quaternion rotation = Quaternion.Euler(y, x, 0);
Vector3 position = rotation * (new Vector3 (0.0f, heightOffset, -distance)) + tank.position;
transform.rotation = rotation;
transform.position = position;
target.position = transform.position + (transform.forward * 100);
}
}
private float ClampAngle(float angle, float min, float max)
{
if (angle < -360)
{
angle += 360;
}
if (angle > 360)
{
angle -= 360;
}
return Mathf.Clamp (angle, min, max);
}
}
剧本:
model:
srx550:
code: 12.3X48-D70.3
path: "/var/tmp/code/juniper/junos-srxsme-12.3X48-D70.3-domestic.tgz"
输出:
tasks:
- include_vars:
file: main.yml
- name: Log into to Juniper device and determine model with facts module
juniper_junos_facts:
host: "{{ inventory_hostname }}"
user: user
port: 22
register: junos
- debug: msg="{{ ['model.' + junos.model|lower + '.path'] }}"
预期输出:
ok: [lab_cpe] => {
"msg": [
"model.srx550.path"
对此将有任何帮助或指导。