3
votes

I use a VM and Intershop 7.8 to run an ansible-playbook (using this tutorial ). After installing Ansible, copying the content of the repository and configuring it (as shown in the "quick installation guide"), I tried to run the ansible-playbook "setupci.yml" using the command ansible-playbook setupci.yml. Testing this the first time the error provided hosts list is empty, only localhost available occurred. Solving this by creating a "hosts.yml" file, in which I declared a hostname and using other commands to run the playbook, two new errors occurred.

I tried the following command in the ci-set-ansible-playbook directory:

$ --limit @[…]/ci-setup-ansible-playbook/setupci

I also tried:

$ ansible-playbook setupci.yml –connection=local

But both caused the errors:

fatal: [127.0.0.1]: FAILED! => {“changed”: false, “connection”: “close”, “content”: “\n \n 404 – Not Found

fatal: [127.0.0.1]: FAILED! => {“failed”: true, “msg”: “the field ‘args’ has an invalid value, which appears to include a variable that is undefined.

1
Which version of ansible are u running?Willem Evertse
the first command is obviously incomplete. For the second, add -vvv, then show us the Ansible command that is being run when that 404 occurs.tedder42
@WillemEvertse : I run ansible version: 2.3.1.0jri
@tedder42 : When I add -vvv I get the following error fatal[127.0.0.1]:FAILED! => { "failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was 'nexus_ishrepo_url' is undefined\n\n The error appears to have been in '/home/intershop1/developer_home/ci-setup-ansible-playbook/roles/nexus/tasks/nexus.yml': line 49,column 3 Error 404 occurs: $ anible-playbook setupci.yml --connection=local --limit @/home/intershop1/developer_home/ci-setup-ansible-playbook/setupci.retryjri
Edit your question, include that text (formatted) and include the play found in the listed file.tedder42

1 Answers

0
votes

I guess ansible can't load the host vars for your host because the hostname that u defined in hosts.yml doesn't match the file name in /etc/ansible/host_vars/ directory. Maybe you didn't rename the sample.yml file, it needs to match the hostname.

See http://docs.ansible.com/ansible/latest/intro_inventory.html

[Update]

I tried out this ansible playbook on a docker centos 7 image. I also have some problem with getting it running correctly. However, i do get a connection. Make sure u copy the content of the git repo to /etc/ansible

/etc/ansible
-rw-r--r--. 1 root root  9191 Sep  7 12:22 LICENSE.md
-rw-r--r--. 1 root root  5672 Sep  7 12:22 README.asciidoc
-rw-r--r--. 1 root root   555 Sep  7 12:22 Vagrantfile
-rw-r--r--. 1 root root 18066 Jun  1 21:49 ansible.cfg
drwxr-xr-x. 2 root root    42 Sep  7 12:26 group_vars
-rw-r--r--. 1 root root  1050 Sep  7 12:31 hosts
-rw-r--r--. 1 root root    97 Sep  7 12:22 ishsystem.yml
-rw-r--r--. 1 root root  9191 Sep  7 12:22 license-2.0.txt
drwxr-xr-x. 9 root root  4096 Sep  7 12:22 roles
-rw-r--r--. 1 root root   138 Sep  7 12:39 setupci.ym

edit the hosts file

##content of hosts
ciserver ansible_connection=local

Check that ansible can connect to the host

ansible all -m ping
ciserver | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

copy the sample.yml in group_var to ciserver.yml (same name as in hosts) file and edit it.

/etc/ansible/group_vars 
-rw-r--r--. 1 root root 1882 Sep  7 12:26 ciserver.yml
-rw-r--r--. 1 root root 1873 Sep  7 12:22 sample.yml

Run the playbook

ansible-playbook setupci.yml

My scripts stops when it tried to start/stop the firewall. The service doesn't exist on centos so it fails. See if u can get this far.

fatal: [ciserver]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service firewalld.service: host"}