小编MMT*_*MMT的帖子

如何使用ansible-vault 2.3.0解密字符串

我一直在等ansible 2.3,因为它将引入encrypt_string功能.

不幸的是,我不确定如何读取加密的字符串.

我确实尝试过decrypt_string,解密(文件),查看(文件),但没有任何作用.

cat test.yml 
---
test: !vault |
     $ANSIBLE_VAULT;1.1;AES256
     37366638363362303836383335623066343562666662386233306537333232396637346463376430
     3664323265333036663736383837326263376637616466610a383430623562633235616531303861
     66313432303063343230613665323930386138613334303839626131373033656463303736366166
     6635346135636437360a313031376566303238303835353364313434363163343066363932346165
     6136
Run Code Online (Sandbox Code Playgroud)

我打算的错误是 ERROR! input is not vault encrypted data for test.yml

如何解密字符串,以便我知道它的价值是什么而不需要运行游戏?

ansible ansible-vault

42
推荐指数
10
解决办法
3万
查看次数

使用租户登录 Azure az

我是 Azure 的新手,所以这个问题可能听起来很愚蠢。

我可以使用CLI 2.0登录Azure中的子帐户吗?

我的意思是拥有一个相当于 powershell 的东西:

Login-AzureRmAccount -TenantId TENANT-GUID -SubscriptionId SUBSCRIPTION-GUID
Run Code Online (Sandbox Code Playgroud)

我正在尝试在我们的子帐户上自动创建应用程序/服务主体。看来,使用 PowerShell,我可以在子帐户上无需任何特定的服务原则来完成此操作,但在搜索有关 Azure CLI 的答案时,尚不清楚这是否可行。

因此,问题是如何通过 Azure CLI 2.0 使用 --tenant 选项连接到子帐户?

azure

6
推荐指数
2
解决办法
4万
查看次数

为什么“docker-compose up”会删除卷?

我正在测试许多作为容器的服务,通常是通过 docker-compose。

因为我是 docker 的新手,所以这个问题可能显得很菜鸟。

在某个时候,我运行了一个 docker-compose 堆栈(几个带有卷的容器)。我必须停止容器才能重新使用相同的端口;我是用命令做到的docker stop

当我准备好再次启动我的容器时,我做了:

$ docker-compose start
Starting jenkins   ... done
Starting gitlab-ce ... done
ERROR: No containers to start
Run Code Online (Sandbox Code Playgroud)

我检查了容器,惊讶地发现:

$ docker-compose ps
Name   Command   State   Ports
------------------------------
Run Code Online (Sandbox Code Playgroud)

所以我跑了:

$ docker-compose up
Creating volume "dockerpipelinejenkins_jenkins_home" with default driver
Creating volume "dockerpipelinejenkins_gitlab_logs" with default driver
Creating volume "dockerpipelinejenkins_gitlab_data" with default driver
Creating volume "dockerpipelinejenkins_gitlab_config" with default driver
Creating dockerpipelinejenkins_jenkins_1   ... done
Creating dockerpipelinejenkins_gitlab-ce_1 ... done
Attaching to dockerpipelinejenkins_jenkins_1, dockerpipelinejenkins_gitlab-ce_1
Run Code Online (Sandbox Code Playgroud)

...我很震惊地发现我的卷已被重新创建,有效地删除了我的数据。

为什么 docker …

docker docker-compose

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

为什么 azure-sdk-for-python 返回对象

我最近开始研究 Azure 的 SDK,但无法弄清楚为什么每个方法(由我测试)都返回一个对象,而不是更“人类”友好的东西,即列表或字典。

IE:

list(compute_client.virtual_machines.list_all())
[<azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93c190>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93c750>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93cad0>, <azure.mgmt.compute.compute.v2017_03_30.models.virtual_machine.VirtualMachine object at 0x7f637f93ced0>]
Run Code Online (Sandbox Code Playgroud)

返回似乎很难与之交互的对象有什么好处,即我需要查找每个方法以找到返回值等等来处理列表,然后构建一个字典,这似乎需要更多的工作。

我在Microsoft 博客 / github之一中找到了这种方法:

def print_item(group):
    """Print a ResourceGroup instance."""
    print("\tName: {}".format(group.name))
    print("\tId: {}".format(group.id))
    print("\tLocation: {}".format(group.location))
    print("\tTags: {}".format(group.tags))
    print_properties(group.properties)
Run Code Online (Sandbox Code Playgroud)

这似乎非常低效IMO能够打印另一种方法的返回值。

有人可以建议为什么“对象列表”比“列表”更好,为什么不返回类似 json.

python azure

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

如何在Python中调用此"操作"

我试图理解这个位是如何工作的:

Var_1, Var_2, Result =  some_function()
Run Code Online (Sandbox Code Playgroud)

剧本:

def some_function():
    return True, False, {"Some": "Dictionary"}

def main():
    Var_1, Var_2, Result =  some_function()
    if not Var_1:
        do something
    else:
        do something_else(Var_2, Result)

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

对我来说,难以理解的是开始做的一点,并提供(返回)值,这些值将在主函数中使用,并在函数some_function()内从同一触发器中使用main().

由于我是python中的高级概念的新手,我发现它非常有趣.如何调用这个"操作",以便我可以阅读更多关于它是如何工作的.即按行顺序返回一些值,,并根据行中的位置解释它们(由于缺乏更好的描述).

python

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

Terraform获取列表的长度

我正在试用Terraform,遇到了当地人。我正在尝试做的是基于另一个变量(env)获取列表的长度。

在尝试评估长度之前如何使Terrform评估变量?

这是我的代码:

locals {
  env = "${terraform.workspace}"

  subnet_names = {
    "default" = ["default_sub1"]
    "dev"     = ["dev_sub1", "dev_sub2", "dev_sub3"]
    "prod"    = ["prod_sub1", "prod_sub2", "prod_sub3"]
  }

}

resource "azurerm_subnet" "subnet" {
  name                      = "${lookup(local.subnet_names, local.env, count.index)}"
  virtual_network_name      = "${azurerm_virtual_network.network.name}"
  resource_group_name       = "${azurerm_resource_group.terraform.name}"
  address_prefix            = "10.0.1.0/24"
  network_security_group_id = "${azurerm_network_security_group.security_group.id}"
  count                     =  "${length(local.subnet_names, local.env)}"
}
Run Code Online (Sandbox Code Playgroud)

当我尝试验证代码时,我得到了length: expected 1 arguments, got 2 in${length(local.subnet_names, local.env)}

这有什么窍门?

terraform

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

如何在Jenkins的pull-request中获取git更改的文件

我使用 docker slaves 运行 Jenkins,我正在尝试获取已更改文件的名称(在合并请求中),以便我可以对这些文件进行一些进一步的自动化。

不幸的是,git diff(--name-only) 的任何变体都不会在 Jenkin 的控制台中产生任何标准输出。git status虽然工作正常。

如何在提交/合并请求中捕获更改文件的名称?它不一定是 CLI,我很高兴使用 web-hooks(gitlab-ce),尽管我还没有看到包含该信息的 CLI。

git jenkins jenkins-plugins

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

curl 发送 JSON 有效负载

我只是在与 RabbitMQ 一起使用,然后尝试向它发送一个 json 有效负载。不幸的是我收到错误:

{"error":"bad_request","reason":"payload_not_string"}
Run Code Online (Sandbox Code Playgroud)

我在某处阅读了我需要使用的内容,"content_type": "application/json"但这也无济于事。

这是我要发送的正文:

{
    "properties": {
        "delivery_mode": 2,
        "content_type": "application/json"
    },
    "routing_key": "git",
    "payload": {
        "action": "created",
        "comment": {
            "url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
            "id": 11056394
        }
    },
    "payload_encoding": "string"
}
Run Code Online (Sandbox Code Playgroud)

和完整的卷曲:

curl -i -X POST \
   -H "Content-Type:application/json" \
   -H "Authorization:Basic Z3Vlc3Q6Z3Vlc3Q=" \
   -d \
'{
    "properties": {
        "delivery_mode": 2,
        "content_type": "application/json"
    },
    "routing_key": "git",
    "payload": {
        "action": "created",
        "comment": {
            "url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
            "id": 11056394
        }
    },
    "payload_encoding": "string"
}' \
 'http://localhost:8090/api/exchanges/%2f/amq.topic/publish'
Run Code Online (Sandbox Code Playgroud)

是否可以发送 json …

rabbitmq rabbitmq-exchange

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