ansible

Ansible: no package available for docker-ce

你离开我真会死。 提交于 2021-02-10 14:46:01
问题 I want to install Docker on a remote machine with Ubuntu 16.04, using Ansible and following the official docs at https://docs.docker.com/engine/installation/linux/ubuntu/. All seems to work, until ansible reaches the task with name "install Docker", I get "No package matching 'docker-ce' is available". The following part of the playbook, from the point where the repository is set: - name: set the stable repository apt_repository: repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu

ansible delegation to other hosts

自作多情 提交于 2021-02-10 13:58:34
问题 I use ansible 2.1 and I want to run a command to a group of hosts, using delegate_to. I use localhost as the host param and I want to delegate a “touch” command to both of cls hosts I have the following --- - hosts: ansible # gather_facts: yes tasks: - debug: var=groups.cls - name: touch a file to running host shell: echo {{ item }} >> /tmp/{{ inventory_hostname }} delegate_to: "{{ item }}" with_items: "{{ groups.cls }}" with output: [root@ansible control]# ansible-playbook -i inventory test

ansible delegation to other hosts

前提是你 提交于 2021-02-10 13:57:27
问题 I use ansible 2.1 and I want to run a command to a group of hosts, using delegate_to. I use localhost as the host param and I want to delegate a “touch” command to both of cls hosts I have the following --- - hosts: ansible # gather_facts: yes tasks: - debug: var=groups.cls - name: touch a file to running host shell: echo {{ item }} >> /tmp/{{ inventory_hostname }} delegate_to: "{{ item }}" with_items: "{{ groups.cls }}" with output: [root@ansible control]# ansible-playbook -i inventory test

What does sleep 0 do in a shell script and what does it do if it used in the ansible SSH config to append after each command?

笑着哭i 提交于 2021-02-10 12:47:53
问题 What does sleep 0 do in a shell script? I read the man page for sleep and it says "delay for a specified amount of time" And the argument NUMBER specifies this time in SECONDS (by default). But I see ansible using sh -c 'echo ~ec2-user && sleep 0' to start with each task. Also, it uses this at the end of each remote command it is firing. I didn't find any special case mention of sleep 0 on the man page and based on the functionality of the sleep command it doesn't make any sense to have sleep

Ansible Special Characters in passwords

主宰稳场 提交于 2021-02-10 12:05:08
问题 I read my root passwords from an encrypted ansible-vault file. But when I use it on ansible_become_pass the operation fails because the password contains a special character. In my example " # " This is my yml: - hosts: sirius remote_user: ansusr become: yes vars_files: - vault_vars.yml become_pass: "{{ root_pass_sirius }}" ansible-playbook check.yml --ask-vault-pass fatal: FAILED! => {"msg": "{{ TesT#1234 }}: template error while templating string: unexpected char '#' at 6. String: {{ TesT

Ansible Special Characters in passwords

谁说胖子不能爱 提交于 2021-02-10 12:00:57
问题 I read my root passwords from an encrypted ansible-vault file. But when I use it on ansible_become_pass the operation fails because the password contains a special character. In my example " # " This is my yml: - hosts: sirius remote_user: ansusr become: yes vars_files: - vault_vars.yml become_pass: "{{ root_pass_sirius }}" ansible-playbook check.yml --ask-vault-pass fatal: FAILED! => {"msg": "{{ TesT#1234 }}: template error while templating string: unexpected char '#' at 6. String: {{ TesT

Ansible error: AttributeError: module 'platform' has no attribute 'dist'

最后都变了- 提交于 2021-02-10 07:35:30
问题 I want to add group in remote machine via ansible playbook and i get error. This is my code from playbook: - name: Ensure group for deploy_user exists become: yes group: name: "{{ deploy_user }}" state: present and this is error what I get: fatal: [webserver]: FAILED! => { "changed": false, "module_stderr": "mux_client_request_session: read from master failed: Broken pipe\r\nShared connection to server closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible

How to filter the latest version of every file in a tree using Ansible?

时光毁灭记忆、已成空白 提交于 2021-02-10 05:58:25
问题 I have a mid-sized directory-tree with variety of files: /some/place/distfiles/foo-1.2.jar /some/place/distfiles/subdir/foo-1.3.jar /some/place/distfiles/bar-1.1.jar /some/place/distfiles/bar-1.1.2.jar I use the find-module to get the full list, but I only need the latest versions for each foo and bar . The above set, for example, needs to be reduced to: /some/place/distfiles/subdir/foo-1.3.jar /some/place/distfiles/bar-1.1.2.jar No, I cannot rely on the files' timestamps -- only on the

Ansible: Check if a variable contains a list or dictionary

风格不统一 提交于 2021-02-10 03:46:09
问题 Sometimes, roles need different mandatory variables that needs to be defined when calling them. For instance - hosts: localhost remote_user: root roles: - role: ansible-aks name: myaks resource_group: myresourcegroup Inside the role, it can be controlled like this: - name: Assert AKS Variables assert: that: "{{ item }} is defined" msg: "{{ item }} is not defined" with_items: - name - resource_group I want to pass a list or dictionary to my role instead of a string. How can I assert that a

Ansible requires python-apt but it's already installed

百般思念 提交于 2021-02-08 13:16:40
问题 Prologue : I am just moving first stesp in ansible, so please be patient Also: I read the answers at 'Ansible demands installing MySQL-python despite it was already installed' but my case is different because locally, on the control machine, is all perfect; thanks to this question I discovered that my problem was in the remote controlled machine. So my questions is the same but the question linked do not contains an answer to resolve my problem . I'm testing ansible from command line. For