Ansible install packages in docker image is hung.

44 views
Skip to first unread message

Toan Huynh Van

unread,
Feb 5, 2020, 4:17:48 AM2/5/20
to Ansible Project
Hi all, 

I am using ansible to install packages for docker image but it's hung with messages below. Can you have a look and give me advice?

    docker:     "stderr_lines": [
    docker:         "",
    docker:         "Extracting templates from packages: 5%",
    docker:         "Extracting templates from packages: 10%",
    docker:         "Extracting templates from packages: 16%",
    docker:         "Extracting templates from packages: 21%",
    docker:         "Extracting templates from packages: 27%",
    docker:         "Extracting templates from packages: 32%",
    docker:         "Extracting templates from packages: 37%",
    docker:         "Extracting templates from packages: 43%",
    docker:         "Extracting templates from packages: 48%",
    docker:         "Extracting templates from packages: 54%",
    docker:         "Extracting templates from packages: 59%",
    docker:         "Extracting templates from packages: 64%",
    docker:         "Extracting templates from packages: 70%",
    docker:         "Extracting templates from packages: 75%",
    docker:         "Extracting templates from packages: 81%",
    docker:         "Extracting templates from packages: 86%",
    docker:         "Extracting templates from packages: 91%",
    docker:         "Extracting templates from packages: 97%",
    docker:         "Extracting templates from packages: 100%",
    docker:         "",
    docker:         "Current default time zone: 'Etc/UTC'",
    docker:         "Local time is now:      Wed Feb  5 09:02:44 UTC 2020.",
    docker:         "Universal Time is now:  Wed Feb  5 09:02:44 UTC 2020.",
    docker:         "Run 'dpkg-reconfigure tzdata' if you wish to change it.",
    docker:         "",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "Building database of manual pages ...",
    docker:         "update-initramfs: deferring update (trigger activated)",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "",
    docker:         "Creating config file /etc/gconf/2/path with new version",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: unknown initscript, /etc/init.d/cgroup-lite not found.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match saslauthd Default-Stop values (1)",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "update-rc.d: warning:  stop runlevel arguments (1) do not match snmpd Default-Stop values (0 1 6)",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "",
    docker:         "Creating config file /etc/default/sysstat with new version",
    docker:         "update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: unknown initscript, /etc/init.d/systemd-logind not found.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "",
    docker:         "(gconftool-2:8576): GConf-WARNING **: Client failed to connect to the D-BUS daemon:",
    docker:         "Unable to autolaunch a dbus-daemon without a $DISPLAY for X11",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start.",
    docker:         "invoke-rc.d: policy-rc.d denied execution of start."
    docker:     ],


Thanks 

Stefan Hornburg (Racke)

unread,
Feb 5, 2020, 4:22:43 AM2/5/20
to ansible...@googlegroups.com
Are you sure that is a problem related to Ansible? Anyway, you didn't post your playbook or tasks so
we can't know what you are trying.

Regards
Racke


> Thanks 
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b77d09b1-f92a-4817-bf6f-6e489dd961ba%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b77d09b1-f92a-4817-bf6f-6e489dd961ba%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Toan Huynh Van

unread,
Feb 5, 2020, 4:37:52 AM2/5/20
to Ansible Project
I run packer to build docker image and use ansible as provisioner. Below is my playbook:

---
- hosts: all
  become: yes
  gather_facts: no
  tasks:
  - name: Hello world
    shell: "echo 'Hello world'"
  - name: Update OS
    command: apt update

#Basic tools
  - name: Install git, zip, unzip, curl, wget, dos2unix, jq
    apt: 
      name: ['git', 'zip' ,'unzip', 'curl', 'wget', 'dos2unix', 'jq']
      state: present
      update_cache: yes
  - name: Install essential tools
    apt:
      name: ['build-essential', 'libcurl4-openssl-dev', 'libxml2-dev', 'mime-support', 'automake', 'libtool', 'software-properties-common']
      state: present
      update_cache: yes
#Python
  - name: Boostrap python
    raw: test -e /usr/bin/python || (apt-get -y update && apt-get install -y python-dev)
  - name: Install pip
    apt:
      name: python-pip
      state: present
      update_cache: yes
  - name: Update pip
    pip:
      name: pip==9.0.3
#Java 
  - name: Add Java 8 repository
    apt_repository: 
      repo: ppa:webupd8team/java
      state: present
      validate_certs: no
      update_cache: yes
  - name: Remove old java versions
    apt:
      name: ['openjdk-7-jdk', 'openjdk-7-jre', 'openjdk-7-jre-headless']
      state: absent
      update_cache: yes
  - name: Edit environment file
    lineinfile:
      path: /etc/environment
      line: JAVA_HOME="/usr/lib/jvm/java-7-oracle/jre/bin/java"
#NodeJS
  - name: Add nodeJS LTS repo
    shell: curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
  - name: Install nodejs
    apt:
      name: nodejs
      state: present
      update_cache: yes
  - name: Update npm
    shell: npm install npm -g
#Go
  - name: Add Go repository
    apt_repository:
      repo: ppa:gophers/go
      state: present
      update_cache: yes
  - name: Install Go
    apt:
      name: golang-go
      state: present
      update_cache: yes
  - name: Update Go environment
    lineinfile:
      path: ~/.bashrc
      line: export="$PATH:/usr/bin/go"
# S3FS tool
#  - name: Get fuse
#    get_url: 
#      dest: /tmp/fuse-2.9.9.tar.gz
#  - name: Untar fuse
#    unarchive:
#      src: /tmp/fuse-2.9.9.tar.gz
#      dest: /tmp/
#      remote_src: yes
#  - name: Compile fuse
#    shell: ./configure --prefix=/usr/local && make && make install && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && echo 'PKG_CONFIG_PATH=/usr/local/lib/pkgconfig' >>/etc/environment && ldconfig && modprobe fuse
#    args:
#      chdir: /tmp/fuse-2.9.9/
#  - name: Get s3fs
#    git:
#      dest: /tmp/s3fs-fuse
#  - name: Compile s3fs
#    shell: ./autogen.sh && ./configure --prefix=/usr/local && make && make install
#    args:
#      chdir: /tmp/s3fs-fuse/
#  - name: Set configuration for s3fs
#    copy:
#      src: ../config/s3fs.cfg
#      dest: /root/.s3cfg
#      mode: '0644'
#Puppet
  - name: Download puppet
    get_url: 
      dest: /tmp/puppetlabs-release-trusty.deb
  - name: Install puppet
    apt: 
      deb: /tmp/puppetlabs-release-trusty.deb
      state: present
      update_cache: yes
# AWS CLI
  - name: create directory .aws
    file:
      path: /root/.aws
      state: directory
      mode: '0644'
  - name: Set configuration for aws
    copy:
      src: ../config/awscredentials.cfg
      dest: /root/.aws/credentials
      mode: '0644'

# Install preconfigured Debian packages
  - name: install apt packages
    apt:
      name: "{{ item }}"
      state: present
      update_cache: yes
    # TODO: Update this with your file
    with_lines: cat ../config/apt.nodejs10-test-pnr-v3.mf 

# Install preconfigured pip packages
  - name: Transfer pip manifest
    copy:
      # TODO: Update this with your file
      src: ../config/pip.nodejs10-test-pnr-v3.mf
      dest: /root/pip.manifest
      mode: '0777'
  - name: install pip manifest
    pip:
      requirements: /root/pip.manifest

# Install preconfigured npm packages
  - name: Transfer npm manifest
    copy:
      # TODO: Update this with your file
      src: ../config/npm.nodejs10-test-pnr-v3.mf
      dest: /root/packages.json
      mode: '0777'
  - name: Install packages based on package.json
    npm:
      global: yes
      
# mount NAS
  - name: Install nfs-common
    apt:
      name: nfs-common
      state: present
      update_cache: yes 
  - name: create directory /mnt/share
    file: 
      path: /mnt/share
      state: directory
      mode: '0644'

Vào 16:22:43 UTC+7 Thứ Tư, ngày 05 tháng 2 năm 2020, Stefan Hornburg (Racke) đã viết:

Stefan Hornburg (Racke)

unread,
Feb 5, 2020, 4:52:47 AM2/5/20
to ansible...@googlegroups.com
On 2/5/20 10:37 AM, Toan Huynh Van wrote:
> I run packer to build docker image and use ansible as provisioner. Below is my playbook:
>

I can't see either docker nor packer in your playbook below.

Regards
Racke
> > ansible...@googlegroups.com <javascript:> <mailto:ansible-proje...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/ansible-project/b77d09b1-f92a-4817-bf6f-6e489dd961ba%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/b77d09b1-f92a-4817-bf6f-6e489dd961ba%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d684bd03-8aec-4648-a3bb-d5b4e0afb3a9%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d684bd03-8aec-4648-a3bb-d5b4e0afb3a9%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc

Toan Huynh Van

unread,
Feb 5, 2020, 5:21:13 AM2/5/20
to Ansible Project
Here is my packer script:

{
  "builders": [
    {
      "type": "docker",
      "communicator": "docker",
      "image": "{{user `base_image`}}",
      "commit": true,
      "run_command": [ "-d", "-i", "-t", "--name", "ubuntu_test", "{{.Image}}", "/bin/bash" ]
    }
 ],
    "provisioners": [
       { 
         "type": "shell",
         "inline": [ "apt-get -y update && apt-get install -y python-dev" ]
},
        {
          "type": "ansible",
          "user": "root",
          "playbook_file": "../ansible/playbook.{{user `image_name`}}.yml",
          "extra_arguments": ["-vvv", "--vault-password-file", "../ansible/vault_password", "--extra-vars", "ansible_host=ubuntu_test ansible_connection=docker ansible_python_interpreter=/usr/bin/python"]
      }
    ],
   "post-processors": [
      {
        "type": "docker-tag",
        "repository": "{{user `repository`}}",
        "tag": "latest"
      },
      {
        "type": "docker-tag",
        "repository": "{{user `repository`}}",
        "tag": "{{user `image_tag`}}"
      },
      {
        "type": "docker-push",
        "ecr_login": true,
        "login_server": "{{user `login_server`}}",
        "aws_access_key": "",
        "aws_secret_key": "",
        "keep_input_artifact": false
      } 
    ]

Stefan Hornburg (Racke)

unread,
Feb 5, 2020, 5:34:24 AM2/5/20
to ansible...@googlegroups.com
On 2/5/20 11:21 AM, Toan Huynh Van wrote:
> Here is my packer script:
>

Sorry, I can't really see a relationship between your Ansible playbook and the error message you posted.
Did you try to run the playbook manually?

Regards
Racke

>
> {
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4285ba3a-1d22-4967-b2e4-83d7fe301a80%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/4285ba3a-1d22-4967-b2e4-83d7fe301a80%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc
Reply all
Reply to author
Forward
0 new messages