ansible

ansible print ec2_tag register list

丶灬走出姿态 提交于 2021-01-29 16:49:13
问题 i have this simple task which i get ec2 instance tgs i like to print out the return list of values . - name: get my tagging local_action: module: ec2_tag region: "{{ region }}" resource: "{{ instance_id }}" state: list register: my_ec2_tags tags: - spots this don't print me any value - name: Display all ec2_tags debug: var: my_ec2_tags verbosity: 3 how can i print all the values of my_ec2_tags so i could know if it was set right ? 回答1: Seems you are using tags while running the play. In that

How to stop all containers with Ansible

我怕爱的太早我们不能终老 提交于 2021-01-29 12:58:27
问题 I am trying to stop all running containers as a first step and then remove them. I know that I can do it using Anslible shell package and run this command: docker container stop $(docker container ls -aq) As a second step I can do the same with shell package and clean the dead containers / images / volumes: docker system prune -a -f --volumes I have tried something like this (sample of code): - name: Stop all containers: shell: "docker container stop $(docker container ls -aq)" ignore_errors:

How to stop all containers with Ansible

折月煮酒 提交于 2021-01-29 12:17:06
问题 I am trying to stop all running containers as a first step and then remove them. I know that I can do it using Anslible shell package and run this command: docker container stop $(docker container ls -aq) As a second step I can do the same with shell package and clean the dead containers / images / volumes: docker system prune -a -f --volumes I have tried something like this (sample of code): - name: Stop all containers: shell: "docker container stop $(docker container ls -aq)" ignore_errors:

Which comes first - creating the nginx site `.conf` file or running `certbot-auto certonly`?

孤人 提交于 2021-01-29 12:14:49
问题 I'm trying to automate the setup of certbot + nginx on a server using Ansible. The first time it runs, there are no letsencrypt certificates (yet). However I create the nginx conf as follows, referencing SSL/cert directories that will be created by certbot server { listen 443 ssl; server_name example.co; # ... # SSL ssl_certificate /etc/letsencrypt/live/example.co/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.co/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf;

How to retrieve credentials of a created Google Kubernetes (GKE) cluster in Ansible?

北城以北 提交于 2021-01-29 09:34:38
问题 I'm creating a cluster and node pool with - name: "Create Google Kubernetes Engine Cluster to be setup with with kubectl" gcp_container_cluster: name: "{{cluster_name}}" project: "{{project_id}}" auth_kind: "serviceaccount" location: "{{cluster_location}}" logging_service: "none" monitoring_service: "none" service_account_contents: "{{service_account_contents}}" initial_node_count: 1 register: cluster - name: "Create node pool for system pods" gcp_container_node_pool: name: "default-pool"

How to create/join vars in Ansible

懵懂的女人 提交于 2021-01-29 08:48:55
问题 I need to create a string for a configuration file. It needs to be in this format: nodes = ["node1","node2","node3"] I was originally trying to do this by reading the hosts from a specific group in hosts, but decided it would be better to use a vars file. in my vars file I have --- nodes: - node: node1 - node: node2 - node: node3 I then want to use the lineinfile function to update the config: - name: Update cluster nodes lineinfile: path: /etc/nodes.txt regexp: '^#nodes:' line: "nodes: [

Ansible - Environment variables setting

心已入冬 提交于 2021-01-29 08:46:52
问题 I need to set the environment in the target machine. The environment variables are present in the file called .env337. There are several variables inside that file like export AB_HOME=/tl/dev/abinitio/abinitio-V3 #/gcc3p32 # for 32-bit export PATH=${AB_HOME}/bin:${PATH} I have tried the below playbook to set the environment and register the environment variables in order to use them in the environment keyword to run the other commands in the registered environment, but it didn't worked. -

Interactive password support for Ansible clone of Azure Repository

前提是你 提交于 2021-01-29 08:07:52
问题 What specific syntax needs to be used to get Ansible to clone a git repository from Azure Repositories? The repository URL is https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName and we are able to clone it manually in an interactive shell by providing a requested password which we possess as follows: $ git clone https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName Password for 'https://OrganizationName@dev.azure.com':

Interactive password support for Ansible clone of Azure Repository

房东的猫 提交于 2021-01-29 07:58:54
问题 What specific syntax needs to be used to get Ansible to clone a git repository from Azure Repositories? The repository URL is https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName and we are able to clone it manually in an interactive shell by providing a requested password which we possess as follows: $ git clone https://OrganizationName@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName Password for 'https://OrganizationName@dev.azure.com':

ansible-playbook流程控制-loops循环使用

眉间皱痕 提交于 2021-01-29 06:32:03
1. ansible-playbook流程控制-loops循环使用 有时你想要多次重复任务。在计算机编程中,这称为循环。common ansible循环包括使用文件模块更改多个文件和/或目录的所有权,使用用户模块创建多个用户,并重复轮询步骤,直到达到某个结果。ansible提供两个用于创建循环的关键字:loop和with_<lookup> 注意: 我们loop在ansible 2.5中添加了,他尚未完全替代with_<lookup>,但我们建议大多数用例。 我们还没弃用with_<lookup> 该语法乃然有效 2. 循环示例1: 2.1) 示例1:with_list直接替换为loop 1 - name: with_list 2 debug: 3 msg: " {{ item }} " 4 with_list: 5 - one 6 - two 7 8 - name: with_list -> loop 9 debug: 10 msg: " {{ item }} " 11 loop: 12 - one 13 - two 3. 案例:循环操作 3.1) 案例1:with_list直接替换为loop 1 [root@test-1 loops] # vim loops_test1.yaml 2 [root@test-1 loops] # cat loops_test1.yaml 3 ---