ansible

Fetch module returns “unable to calculate the checksum of the remote file” while running in Docker but works fine when not in Docker

梦想的初衷 提交于 2020-06-01 05:56:09
问题 Ansible playbook (copy_file.yml): - name: Copy this file over please hosts: all gather_facts: false tasks: - name: Get files from scanners running in each DC fetch: src: /tmp/file_to_copy dest: /tmp/local_place flat: yes fail_on_missing: yes validate_checksum: no Command : ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory playbook/copy_file.yml It works when I run it. But when I dockerize it, it gives me the error : fatal: [remotehost.com]: FAILED! => {"changed": false, "file": "

Ansible copy module requires writable parent directory?

久未见 提交于 2020-06-01 04:28:13
问题 Need to set /proc/sys/net/ipv4/conf/all/forwarding to 1 That's can be easily done via command - name: Enable IPv4 traffic forwarding command: echo 1 > /proc/sys/net/ipv4/conf/all/forwarding But that's bad practice - it will be always "changed" task. So I tried the following: - name: Enable IPv4 traffic forwarding copy: content=1 dest="/proc/sys/net/ipv4/conf/all/forwarding" force=yes Which failed with msg: "Destination /proc/sys/net/ipv4/conf/all not writable" According to sources seems like

Ansible: how to parse XML values from URI (REST) xml output

烈酒焚心 提交于 2020-05-31 05:58:31
问题 i have below Ansible playbook to access my server and fetch data using REST API mechanism, and i am able to get output XML format, but struggling to parse only specific values from that output. Ansible Playbook - debug - debug: var: steering - debug: msg="{{ steering | regex_findall('<name>(.*?)</name>') }}" - debug: msg="{{ steering | regex_findall('<value>(.*?)</value>') }}" Output of last 2 debug responses TASK [debug] ***********************************************************************

Combining the output of multiple loops in Ansible

↘锁芯ラ 提交于 2020-05-29 12:24:05
问题 I am working with Ansible and in my playbook I am running the following task, in which I have multiple loops so as to retrieve different tags from a specific xml: - name: Retrieve multiple xml tags valuei xml: xmlstring: "{{ item.string }}" xpath: "{{ item.path }}" content: text loop: - { path: "/rpc-reply/vlan-instance-information/vlan-instance-group/vlan-member/vlan-tag", string: "{{topology.xml}}" } - { path: "/rpc-reply/vlan-instance-information/vlan-instance-group/vlan-member/vlan-member

Unable to get “exclude” option working with unarchive module

﹥>﹥吖頭↗ 提交于 2020-05-29 07:13:48
问题 I have a tar/gzip file I am extracting to a list of hosts using the ansible unarchive module. The following is a partial list of the contents of configs.tgz: -rw-rw-r-- ian/ian 1295 2015-09-25 15:27 Makefile -rw-rw-r-- ian/ian 16 2016-06-21 09:24 .configs drwxrwxr-x ian/ian 0 2016-02-24 10:18 .bash/ -rw-rw-r-- ian/ian 336 2015-09-25 15:27 .bash/apt.b -rw-rw-r-- ian/ian 367 2015-09-25 15:27 .bash/gcloud.b drwxrwxr-x ian/ian 0 2016-06-21 09:22 .vim/ drwxrwxr-x ian/ian 0 2016-06-21 09:22 .vim

ansible: pass variable to a handler

假装没事ソ 提交于 2020-05-28 14:06:07
问题 I use an "eye" as a supervisor and on changes in templates have to runs something like this: eye load service.rb eye restart service.rb I want to define this as a single handler for all the apps and call it like eye reload appname And in a handler operate like this: - name: reload eye service command: eye load /path/{{ service }}.rb && eye restart {{ service }} But I can't find a way to pass variable to a handler. Is it possible? 回答1: handlers/main.yml: - name: restart my service shell: eye

ansible: pass variable to a handler

我与影子孤独终老i 提交于 2020-05-28 14:04:48
问题 I use an "eye" as a supervisor and on changes in templates have to runs something like this: eye load service.rb eye restart service.rb I want to define this as a single handler for all the apps and call it like eye reload appname And in a handler operate like this: - name: reload eye service command: eye load /path/{{ service }}.rb && eye restart {{ service }} But I can't find a way to pass variable to a handler. Is it possible? 回答1: handlers/main.yml: - name: restart my service shell: eye

Ansible: Change playbooks location

情到浓时终转凉″ 提交于 2020-05-28 05:02:08
问题 I have all playbooks in /etc/ansible/playbooks and I want to execute them anywhere on the pc I tried to configure playbook_dir variable in ansible.cfg [defaults] playbook_dir = /etc/ansible/playbooks/ and tried to put ANSIBLE_PLAYBOOK_DIR variable in ~/.bashrc export ANSIBLE_PLAYBOOK_DIR=/etc/ansible/playbooks/ but I only got the same error in both cases: nor@nor:~$ ansible-playbook test3.yaml ERROR! the playbook: test3.yaml could not be found This is my ansible version: ansible 2.9.7 config

Ansible: Change playbooks location

纵然是瞬间 提交于 2020-05-28 05:00:26
问题 I have all playbooks in /etc/ansible/playbooks and I want to execute them anywhere on the pc I tried to configure playbook_dir variable in ansible.cfg [defaults] playbook_dir = /etc/ansible/playbooks/ and tried to put ANSIBLE_PLAYBOOK_DIR variable in ~/.bashrc export ANSIBLE_PLAYBOOK_DIR=/etc/ansible/playbooks/ but I only got the same error in both cases: nor@nor:~$ ansible-playbook test3.yaml ERROR! the playbook: test3.yaml could not be found This is my ansible version: ansible 2.9.7 config

Ansible create postgresql user with access to all tables?

僤鯓⒐⒋嵵緔 提交于 2020-05-26 10:25:39
问题 This should be very simple. I want to make an Ansible statement to create a Postgres user that has connection privileges to a specific database and select/insert/update/delete privileges to all tables within that specific database. I tried the following: - name: Create postgres user for my app become: yes become_user: postgres postgresql_user: db: "mydatabase" name: "myappuser" password: "supersecretpassword" priv: CONNECT/ALL:SELECT,INSERT,UPDATE,DELETE I get relation \"ALL\" does not exist