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: 
#      url: 
https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz
#      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:
#      repo: https://github.com/s3fs-fuse/s3fs-fuse.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: 
      url: http://apt.puppetlabs.com/puppetlabs-release-trusty.deb
      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:
>
> On 2/5/20 10:17 AM, Toan Huynh Van wrote: 
> > 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:     ], 
> > 
> > 
>
> 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 
> > [email protected] <javascript:> <mailto:
> [email protected] <javascript:>>. 
> > 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. 
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d684bd03-8aec-4648-a3bb-d5b4e0afb3a9%40googlegroups.com.

Reply via email to