小编4c7*_*b41的帖子

Jinja:迭代列表以创建 yaml 元素数组

我在 ansible playbook 中有以下变量

var1: "string"
variable:
  - name: "{{ var1 }}-xxx"
    sshKey: "{{ lookup('file', 'temp/xxx.pub') }}"
  - name: "{{ var1 }}-yyy"
    sshKey: "{{ lookup('file', 'temp/yyy.pub') }}"
  - name: "{{ var1 }}-zzz"
    sshKey: "{{ lookup('file', 'temp/zzz.pub') }}"
Run Code Online (Sandbox Code Playgroud)

这显然需要一个循环。然而,我尝试创建一个循环是徒劳的。

list: [ 'zzz', 'xxx', 'yyy' ]
loop: [
{% for item in list %}
- name: "{{ item }}"
  sshKey: "{{ lookup('file', 'temp/{{ item }}.tmp') }}"
{% endfor %}
]
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?我有点失落。

templates yaml jinja2 ansible

1
推荐指数
1
解决办法
5249
查看次数

Jinja:if语句里面的字符串变量

我正在尝试在jinja中创建以下循环:

variable: >
[
    {% for replaceme in list %}
    {
        'name': "{{ "string-{{replaceme}}" if replaceme == 'somevalue' else "string-something-{{replaceme}}" }}",
        'sshKey': "{{ lookup(...) }}"
    }
    {% if not loop.last %},{% endif %}
    {% endfor %}
]
Run Code Online (Sandbox Code Playgroud)

但这不起作用,任何想法?我尝试了不同的引号,不同的curlies组合等.

python configuration jinja2 ansible

1
推荐指数
1
解决办法
3669
查看次数

手臂模板中的多个条件

有没有办法在手臂模板中实现这一点?条件在哪里有多个部分?

{
      "type": "Microsoft.Web/sites/config",
      "name": "[variables('website_notProduction_config')]",
      "condition": "[not(parameters('is_Production')) and equals(parameters('is_Not_Development'), 'True')]",
Run Code Online (Sandbox Code Playgroud)

azure azure-rm-template

1
推荐指数
1
解决办法
4177
查看次数

使用ARM模板锁定资源组

嗨我试图使用ARM模板锁定azure中的资源组但我不能这样做,如果有人已经熟悉,请帮助我.

azure azure-rm-template azure-resource-group

1
推荐指数
1
解决办法
1080
查看次数

如何在带有事件中心的ARM模板中使用listkeys函数

我有一个如下所示的事件中心: 在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

我已经为服务总线成功完成了此操作,但仅针对高级RootManageSharedAccessKey了

但是,对于事件中心,我希望使用SendOnly共享访问策略的主连接字符串。

我尝试了许多组合,但是在部署部署时找不到SendOnly共享访问策略。

这是我的SendOnly共享访问策略的json。

在此处输入图片说明

任何帮助将不胜感激。

azure azure-eventhub azure-resource-manager azure-keyvault azure-rm-template

1
推荐指数
2
解决办法
1982
查看次数

Azure Kubernetes 服务 (AKS) 保留 VM?

我的问题是:

如何预留 Azure Kubernetes 服务 (AKS) VM?

https://azure.microsoft.com/en-us/pricing/calculator/

在定价计算器中显示我可以将 VM 保留 3 年,这在购买 VM 时存在,但在购买 AKS 时没有

什么是流量?

我应该保留为 VM,然后致电支持并从 ASK 流中转移它们吗?

我在这里问这个问题是因为微软有链接 Stackoverflow 是“社区”论坛

https://azure.microsoft.com/en-us/support/community/

在此处输入图片说明

azure kubernetes azure-aks

1
推荐指数
1
解决办法
2136
查看次数

在Azure Devops中,从Bitbucket提取时如何选择Yaml管道

从Azure Devops存储库提取代码时,您可以选择基于yaml文件配置生成管道:

yaml管道
但是,当使用bitbucket作为存储库时,此选项不可用。是否可以将YAML“配置作为代码”与BitBucket存储库一起使用?

git bitbucket azure azure-devops

1
推荐指数
1
解决办法
185
查看次数

手臂模板中的 copyindex() 错误

这是我的参数文件:

"VNetSettings": {
    "value": {
        "name": "VNet1",
        "addressPrefixes": "10.0.0.0/16",
        "subnets": [
            {
                "name": "sub1",
                "addressPrefix": "10.0.1.0/24"
            },
            {
                "name": "sub2",
                "addressPrefix": "10.0.2.0/24"
            }
        ]
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的部署文件(deploy.json)

{
    "contentversion": "1.0.0.0",
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "parameters": {
        "VNetSettings": {
            "type": "object"
        },
        "noofsubnets": {
            "type": "int"
        }
    },
    "resources": [
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[parameters('VNetSettings').name]",
            "location": "[resourceGroup().location]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[parameters('VNetSettings').addressPrefixes]"
                    ]
                },
                "copy": {
                    "name": "subnets",
                    "count": "[parameters('noofsubnets')]",
                    "input": {
                        "name": "[parameters('VNetSettings').subnets[copyIndex('subnets',1)].name]",
                        "properties": {
                            "addressPrefix": "[parameters('VNetSettings').subnets[copyIndex('subnets',1)].addressPrefix]"
                        } …
Run Code Online (Sandbox Code Playgroud)

json azure azure-powershell azure-rm-template

0
推荐指数
1
解决办法
2638
查看次数

Azure kubernetes 在门户上缩放和显示

我在 azure kubernetes 上部署了应用程序。当我创建 azure kubernetes 集群时,它是单个节点,我假设它是 1 个虚拟机。

现在我扩展了我的部署。

kubectl scale --replicas=3 deployment/kubdemo1api
Run Code Online (Sandbox Code Playgroud)

在此之后我发射 kubectl get pods

kubdemo1api-776dfc99cc-c72qg   1/1       Running   0          1m
kubdemo1api-776dfc99cc-n7xvs   1/1       Running   0          1m
kubdemo1api-776dfc99cc-xghs5   1/1       Running   0          13m
Run Code Online (Sandbox Code Playgroud)

这告诉我现在有 3 个部署实例正在运行。

但是,如果我转到 azure 门户 kubernetes 集群。

我仍然继续看到 1 node 。这让我很困惑,关于如何在 aks 中进行扩展以及扩展的实例在哪里部署。

azure kubernetes azure-aks

0
推荐指数
1
解决办法
207
查看次数

容器环境变量更改时如何强制重新启动Pod

我正在尝试部署对环境变量有一些更改的映像,但是当我这样做时,我遇到了错误

该吊舱“ENVAR-演示”是无效的:规范:禁止:荚更新可能不会改变比其他领域spec.containers[*].imagespec.initContainers[*].imagespec.activeDeadlineSeconds或者 spec.tolerations(仅对现有容差的补充){“ Volumes”:[{“ Name”:“ default-token-9dgzr”,“ HostPath”:null,“ EmptyDir”:null,“ GCEPersistentDisk”:null,“ AWSElasticBlockStore”:null, “ GitRepo”:null,“ Secret”:{“ SecretName”:“ default-token-9dgzr”,“ Items”:null,“ DefaultMode”:420,“ Optional”:null},“ NFS”:null,“ ISCSI “:null,” Glusterfs“:null,” PersistentVolumeClaim“:null,” RBD“:null,” Quobyte“:null,” FlexVolume“:null,” Cinder“:null,” CephFS“:null,” Flocker“: null,“ DownwardAPI”:null,“ FC”:null,“ AzureFile”:null,“ ConfigMap”:null,“ VsphereVolume”:null,“ AzureDisk”:null,“PhotonPersistentDisk”:null,“ Projected”:null,“ PortworxVolume”:null,“ ScaleIO”:null,“ StorageOS”:null}],“ InitContainers”:null,“ Containers”:[{“ Name”:“ envar- demo-container“,” Image“:” gcr.io/google-samples/node-hello:1.0","Command":null,"Args":null,"WorkingDir":"","Ports":null, “ EnvFrom”:null,“ Env”:[{“ Name”:“ DEMO_GREETING”,“ Value”:“来自环境的问候0“,” Command“:null,” Args“:null,” WorkingDir“:”“,” Ports“:null,” EnvFrom“:null,” Env“:[{” Name“:” DEMO_GREETING“,” Value “:”您好,来自环境0“,” Command“:null,” Args“:null,” WorkingDir“:”“,” Ports“:null,” EnvFrom“:null,” Env“:[{” Name“:” DEMO_GREETING“,” Value “:”您好,来自环境 …

pod azure kubernetes azure-kubernetes azure-aks

0
推荐指数
1
解决办法
73
查看次数

为什么队列绑定在 Azure 中不起作用?

我正在尝试使用队列触发器创建一个函数,这是function.json

  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "CraigslistItemParser",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "craigslist",
      "connection": "DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY;EndpointSuffix=core.windows.net"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

在控制台日志中部署该函数时,出现错误:

The 'CraigslistItemParser' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.CraigslistItemParser'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string 'DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY;EndpointSuffix=core.windows.net' does not exist. Make sure that it is a defined App Setting.
Run Code Online (Sandbox Code Playgroud)

什么是应用程序设置,我在任何地方都找不到它们?

azure python-3.x azure-queues azure-functions

0
推荐指数
1
解决办法
1003
查看次数

VM classic 不断关闭并自行释放分配

我使用 Windows Server 2016 操作系统创建了一个新的经典 Azure VM。它似乎运行了大约 20 小时左右,然后自行关闭并释放分配。

我已搜索虚拟机上的事件查看器日志,但看不到任何表明关闭原因的内容。

azure azure-virtual-machine

-1
推荐指数
1
解决办法
2050
查看次数