diff options
-rw-r--r-- | ansible/ansible.cfg | 1 | ||||
-rw-r--r-- | ansible/docker/Dockerfile | 1 | ||||
-rw-r--r-- | ansible/infrastructure.yml | 4 | ||||
-rw-r--r-- | ansible/inventory/hosts.yml | 4 | ||||
-rw-r--r-- | ansible/roles/docker/tasks/main.yml | 2 | ||||
-rwxr-xr-x | ansible/run_playbook.sh | 6 |
6 files changed, 15 insertions, 3 deletions
diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index c2ee3ff3..0978b814 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -6,3 +6,4 @@ # relative path ./application is mapped into ansible container under # /ansible/application where application roles should be found roles_path = /ansible/application +log_path = /ansible/log/ansible.log diff --git a/ansible/docker/Dockerfile b/ansible/docker/Dockerfile index b0172709..4cefa8b7 100644 --- a/ansible/docker/Dockerfile +++ b/ansible/docker/Dockerfile @@ -24,6 +24,7 @@ RUN apk --no-cache update \ && pip3 install --no-cache-dir \ ansible==$ansible_version \ jmespath \ + netaddr \ && apk del build-dependencies && rm -rf /var/cache/apk/* ENV ANSIBLE_HOST_KEY_CHECKING false diff --git a/ansible/infrastructure.yml b/ansible/infrastructure.yml index 789f8716..08667330 100644 --- a/ansible/infrastructure.yml +++ b/ansible/infrastructure.yml @@ -4,7 +4,7 @@ tasks: - name: Setup resolv.conf lineinfile: - line: "nameserver {{ hostvars[groups.infrastructure[0]].ansible_host }}" + line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}" path: /etc/resolv.conf state: present insertbefore: BOF @@ -61,7 +61,7 @@ - role: nexus vars: phase: runtime-populate - when: runtime_images is defined + when: runtime_images is defined and runtime_images is not none - name: Setup base for Kubernetes nodes hosts: kubernetes diff --git a/ansible/inventory/hosts.yml b/ansible/inventory/hosts.yml index f11ef7b1..a29072c5 100644 --- a/ansible/inventory/hosts.yml +++ b/ansible/inventory/hosts.yml @@ -20,12 +20,16 @@ all: hosts: infrastructure-server: ansible_host: 10.8.8.13 + #IP used for communication between infra and kubernetes nodes, must be specified. + cluster_ip: 10.8.8.13 # This is group of hosts which are/will be part of Kubernetes cluster. kubernetes: hosts: kubernetes-node-1: ansible_host: 10.8.8.19 + #ip of the node that it uses for communication with k8s cluster. + cluster_ip: 10.8.8.19 nfs-server: hosts: diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index 9851d4dc..09e790a4 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -20,7 +20,7 @@ json_add: path: /etc/docker/daemon.json key: dns - value: "{{ hostvars[groups.infrastructure[0]].ansible_default_ipv4.address }}" + value: "{{ hostvars[groups.infrastructure[0]].cluster_ip }}" notify: - Restart Docker diff --git a/ansible/run_playbook.sh b/ansible/run_playbook.sh index 9a2ca56f..2edbe358 100755 --- a/ansible/run_playbook.sh +++ b/ansible/run_playbook.sh @@ -25,6 +25,7 @@ script_path=$(readlink -f "$0") script_name=$(basename "$script_path") ANSIBLE_DIR=$(dirname "$script_path") ANSIBLE_CHROOT="${ANSIBLE_DIR}/ansible_chroot" +ANSIBLE_LOG_PATH="/ansible/log/ansible-$(date +%Y.%m.%d-%H%M%S).log" # @@ -82,6 +83,8 @@ REQUIREMENTS: # run playbook # +export ANSIBLE_LOG_PATH + # if no arg then print help and exit if [ -z "$1" ] ; then help @@ -101,6 +104,8 @@ if [ -n "$ANSIBLE_DOCKER_IMAGE" ] ; then -v "$ANSIBLE_DIR:/ansible:ro" \ -v "$ANSIBLE_DIR/application:/ansible/application:rw" \ -v "$ANSIBLE_DIR/certs/:/certs:rw" \ + -v "$ANSIBLE_DIR/log/:/ansible/log:rw" \ + -e ANSIBLE_LOG_PATH \ -it "${ANSIBLE_DOCKER_IMAGE}" "$@" fi @@ -123,6 +128,7 @@ fi --mount rw:"${HOME}/.ssh":/root/.ssh \ --mount ro:"$ANSIBLE_DIR":/ansible \ --mount rw:"$ANSIBLE_DIR"/application:/ansible/application \ + --mount rw:"$ANSIBLE_DIR"/log:/ansible/log \ --mount rw:"$ANSIBLE_DIR"/certs:/certs \ --mount ro:/etc/resolv.conf:/etc/resolv.conf \ --mount ro:/etc/hosts:/etc/hosts \ |