I am using the apt-get install the pure-ftp on ubuntu server 14.04.4
sudo apt-get install pure-ftpd
sudo pure-uploadscript -B -r /home/john/hello.sh
the hell.sh file, and it's able to run.
#!/bin/sh
echo "hello"
Then, I use FileZilla to upload the file. I can upload the file, but the script is not called. please help;
official doc
If you install the pure-ftpd server by apt-get, it may not give you the feature that you want to use. I checked the /var/run folder, some file are missing there. I complied the code with --with-uploadscript, it's working now.
I had to also compile from source, fortunately the install is not too heavy. It may be worth uploading the compiled files from your system to your mirror and just downloading and running make install. On the other hand, this works as well:
- name: install pure-ftpd from source
block:
- name: create required pure-ftpd dirs
become: yes
file:
path: /etc/pure-ftpd
state: directory
owner: root
mode: 0755
- name: install deps for building pureftpd
apt: pkg={{ item }} state=present
with_items:
- libssl-dev
- libpam0g-dev
- name: download and unpack pure-ftpd source
unarchive:
src: http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz
dest: /usr/local/src/
remote_src: yes
keep_newer: yes
register: source_unpack
- name: configuring pure-ftpd source with custom modules
command: "./configure --prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec
--datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/usr/com --localstatedir=/var --libdir=/usr/lib64
--includedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --with-virtualchroot --with-everything
--with-uploadscript --with-tls --with-pam"
args:
chdir: /usr/local/src/pure-ftpd-1.0.49
when: source_unpack|changed
register: pure_ftpd_configure
- name: make and install pure-ftpd
become: yes
shell: make && make install
args:
chdir: /usr/local/src/pure-ftpd-1.0.49
when: pure_ftpd_configure|changed
when: stat_result.stat.exists == False
tags:
- ftp
Related
I'm installing ruby from source and using template to export path. My code looks like this:
- name: clone rbenv
git: repo=git://github.com/sstephenson/rbenv.git dest=/usr/local/rbenv
become: yes
- template: src=templates/rbenv.sh.j2 dest=/etc/profile.d/rbenv.sh
become: true
- name: clone ruby-build repo
git: repo=git://github.com/sstephenson/ruby-build.git dest=~/ruby-build
- name: Install ruby-build
shell: ./ruby-build/install.sh
become: yes
- name: install jruby
shell: . /etc/profile.d/rbenv.sh && rbenv install jruby-9.0.5.0
become: yes
I want to use command "rbenv",
this works but in this way I have to source profile with every command.
Is there any way to source profile once in ansible.config file or something else and use it in the whole project without sourcing profile again.
Either add path in .bashrc
or
- name: install jruby
shell: . /etc/profile.d/rbenv.sh && rbenv install jruby-9.0.5.0
become: yes
args:
executable: /bin/bash -l
/bin/bash -l behaves as login shell
For installing the node 6.x version these are the commands:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
now how exactly do I do that in ansible?
any ideas here?
this is what I had till now, but it installs the old version
---
- name: Ensure Ubuntu Distro is Supported
get_url:
url='https://deb.nodesource.com/node/dists/"{{ ansible_distribution_release }}"/Release'
dest=/dev/null
register: distrosupported
- name: Remove Old Chris Lea PPA
apt_repository:
repo='ppa:chris-lea/node.js'
state=absent
when: distrosupported|success
ignore_errors: yes
- name: Remove Old Chris Lea Sources
sudo: yes
file:
path='/etc/apt/sources.list.d/chris-lea-node_js-"{{ ansible_distribution_release }}".list'
state=absent
when: distrosupported|success
ignore_errors: yes
- name: Add Nodesource Keys
sudo: yes
apt_key:
url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state=present
- name: Add Nodesource Apt Sources List Deb
sudo: yes
apt_repository:
repo='deb https://deb.nodesource.com/node "{{ ansible_distribution_release }}" main'
state=present
when: distrosupported|success
- name: Add Nodesource Apt Sources List Deb Src
sudo: yes
apt_repository:
repo='deb-src https://deb.nodesource.com/node "{{ ansible_distribution_release }}" main'
state=present
when: distrosupported|success
- name: Install NodeJS
sudo: yes
apt: pkg=nodejs state=latest update_cache=true
when: distrosupported|success
- debug: msg="{{npm_pkgs}}"
- name: install global npm packages
sudo: yes
npm: name={{item}} global=yes state=latest
with_items: "{{npm_pkgs}}"
I was using this playbook for installing node 6.1.0 via nvm(node version manager):
Note: You may need to change the hosts and connection in the play.
---
- hosts: localhost
connection: local
vars:
node_version: 6.1.0
tasks:
- name: Download the nvm(node version manager) install script
get_url: url=https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh dest=/tmp/install.sh
- name: Install dependencies
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
with_items:
- git
- curl
- build-essential
- libssl-dev
become: yes
become_user: root
- name: Execute the nvm install script
shell: bash install.sh chdir=/tmp executable=/bin/bash
- name: Register the NVM_DIR
shell: echo $NVM_DIR
register: nvm_dir
- name: Install the specified node version using the nvm command and set it as default
shell: . {{ nvm_dir.stdout }}/nvm.sh && nvm install {{ node_version }} && nvm run {{node_version}} --version && nvm alias default {{node_version}}
creates=~/.nvm/versions/node/v{{ node_version }}
For more information on nvm, see: https://github.com/creationix/nvm
Based on the code in the original question, and the helpful comment from #ydaetskcoR, I was able to install NodeJS 6.x with the following on Ubuntu 16.04:
- name: Add Nodesource Keys
become: yes
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
# Note: "xenial" is ubuntu-speak for 16.04
- name: Add Nodesource Apt Sources
become: yes
apt_repository:
repo: '{{ item }}'
state: present
with_items:
- 'deb https://deb.nodesource.com/node_6.x xenial main'
- 'deb-src https://deb.nodesource.com/node_6.x xenial main'
- name: Install NodeJS and NPM
become: yes
apt:
name: '{{ item }}'
state: latest
update_cache: yes
with_items:
- nodejs
- nodejs-legacy
- npm
I've refactored a little for brevity, but the most important thing is the addition of _6.x to the repository URLs.
This worked for me using Ansible 2.3.2.0
I want to install python3.x by use pyenv with ansible.
- name: install pyenv
git: >
repo=https://github.com/pyenv/pyenv.git
dest=/home/www/.pyenv
accept_hostkey=yes
become: yes
become_user: www
- name: enable pyenv
shell: |
echo 'export PYENV_ROOT="/home/www/.pyenv"' >> /home/www/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/www/.bashrc
echo 'eval "$(pyenv init -)"' >> /home/www/.bashrc
- name: install python
shell: pyenv install 3.4.3
How to install python3.x with ansible?
So here is what worked for me well to get any version of python installed with ansible and make it an alternative installation. I first ran configure and make, later compressed the result since this takes a while, then re-distributed the file using a mirror so I can run make altinstall on its own. Here is the recipe:
---
# Check the alt python3 version
- name: check alt python version
shell: /usr/local/bin/python3.6 --version
register: python3_version
ignore_errors: yes # If not installed
tags:
- python-alt
# Stuff I did manually to compile everything first by hand
# Python3 alt-install - steps to create binary:
# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
# tar xf Python-3.6.4.tgz
# mv Python-3.6.4 Python-3.6.4-binary && cd Python-3.6.4-binary
# ./configure --prefix=/usr/local --enable-optimizations
# cd .. && tar -zcvf Python-3.6.4-binary.tar.gz Python-3.6.4-binary (upload to mirror servers)
# make && sudo make altinstall UNINST=1
- name: download and unpack alternative python3
unarchive:
src: http://www.yourmirror.com/centos/python/Python-3.6.4-binary.tar.gz dest=/tmp/Python-3.6.4-binary.tar.gz
dest: /tmp
remote_src: yes
keep_newer: yes
when: python3_version['stderr'] != 'Python 3.6.4'
tags:
- python-alt
# Its possible to install (instead of altinstall) python3 here
- name: make install alt python3
make:
chdir: /tmp/Python-3.6.4-binary
target: altinstall
params:
UNINST: 1 # Replace
when: python3_version['stderr'] != 'Python 3.6.4'
become: yes
tags:
- python-alt
- name: download get-pip.py
get_url:
url: https://bootstrap.pypa.io/get-pip.py
dest: /tmp/get-pip.py
mode: 0664
tags:
- python-alt
- name: install pip for python3
shell: /usr/local/bin/python3.6 /tmp/get-pip.py
become: yes
tags:
- python-alt
# We need virtualenv installed under py3 for the virtualenv command to work
- pip:
name: virtualenv
executable: /usr/local/bin/pip3.6
become: True
tags:
- python-alt
If you want to compile everything on your server you could do the following before the altinstall step and also download the source code package instead of the pre-compiled tar. I don't recommend doing it this way because it does take up resources and you don't want to be doing it in prod. Using Python2.7.14 as an example:
---
# Build the default target
- debug:
var: python2_version
tags:
- python_alt
- make:
chdir: /tmp/Python-2.7.14-binary
when: python2_version['stderr'] != 'Python 2.7.14'
tags:
- python_alt
- name: configure target command
command: ./configure --prefix=/usr/local --enable-optimizations chdir=/tmp/Python-2.7.14-binary
when: python2_version['stderr'] != alt_python_version
tags:
- python_alt
Rather than using the shell module to set environment variables on the remote host, Ansible has the environment keyword, which can set per task or even per playbook.
Assuming the www user already exists I managed to get this working with some more specific path setting:
- name: enable pyenv and install python
shell: /home/www/.pyenv/bin/pyenv init - && /home/www/.pyenv/bin/pyenv install 3.4.3 chdir=/home/www
environment:
pyenv_root: /home/www/.pyenv
path: "{{ pyenv_root }}/bin:$PATH"
become: yes
become_user: www
You will need to run the playbook with:
ansible-playbook --ask-become-pass <playbook-name>
and supply the password for the www user on request.
If that doesn't work, you might have to post the whole playbook here for us to look at :)
I have the following configuration as .gitlab-ci.yml
but I found out after successfully pass build stage (which
would create a virtualenv called venv), it seems that
in test stage you would get a brand new environment(there's
no venv directory at all). So I wonder should I put setup
script in before_script therefor it would run in each phase(build/test/deploy). Is it a right way to do it ?
before_script:
- uname -r
types:
- build
- test
- deploy
job_install:
type: build
script:
- apt-get update
- apt-get install -y libncurses5-dev
- apt-get install -y libxml2-dev libxslt1-dev
- apt-get install -y python-dev libffi-dev libssl-dev
- apt-get install -y python-virtualenv
- apt-get install -y python-pip
- virtualenv --no-site-packages venv
- source venv/bin/activate
- pip install -q -r requirements.txt
- ls -al
only:
- master
job_test:
type: test
script:
- ls -al
- source venv/bin/activate
- cp crawler/settings.sample.py crawler/settings.py
- cd crawler
- py.test -s -v
only:
- master
adasd
Gitlab CI jobs supposed to be independent, because they could run on different runners. It is not issue. There two ways to pass files between stages:
The right way. Using artefacts.
The wrong way. Using cache. With cache key "hack". Still need same runner.
So yes, supposed by gitlab way to have everything your job depends on in before script.
Artifacts example:
artifacts:
when: on_success
expire_in: 1 mos
paths:
- some_project_files/
Cache example:
cache:
key: "$CI_BUILD_REF_NAME"
untracked: true
paths:
- node_modules/
- src/bower_components/
For correct running environment i suggest using docker with image containing apt-get dependencies. And use artefacts for passing job results between jobs. Note that artefact also uploaded to gitlab web interface and being able to download them. So if they are quite heavy use small expire_in time, for removing them after all jobs done.
I haven't used Ansible before, does anyone know how to write a simple playbook that uninstalls nano and installs vim on a Linux server? I would imagine you would need to include an option to configure which text editor preference you want after doing the above.
Cheers
edit
This is what I've got so far...
---
# Playbook to uninstall nano and install vim
- hosts: all
remote_user: luca
sudo: yes
tasks:
- name: uninstall nano
action: command: sudo apt-get purge nano
- name: Install vim
action: command: sudo apt-get install vim
tmp.yml
---
- hosts: all
tasks:
- name: nano remove
apt: name=nano state=absent
- name: vim install
apt: name=vim state=present
ansible-playbook tmp.yml
http://docs.ansible.com/apt_module.html
If you are working on fedora/centos/rhel:
---
- hosts: all
tasks:
- name: nano remove
yum: name=nano state=absent
- name: vim install
yum: name=vim state=latest
Refer to doc of yum module . Set proper args for "state": install (present or installed, latest), or remove (absent or removed) a package.
If you want to remove and install with command, you must write without 'action', like this:
tasks:
- name: uninstall nano
command: sudo apt-get purge nano
- name: Install vim
command: sudo apt-get install vim
But it is not recommended, it is better doing with 'absent'.
And I am not sure if can put sudo, so you can connect directly with your root user.
- hosts: all
remote_user: root
sudo: True
I personally find it cleaner with a loop for the installs. For the uninstall just change the "state"
hosts: desktop-linux
tasks:
- name: Install Desktop packages
apt: name={{item}} state=installed
with_items:
- meld
- synergy
- retext
- pidgin
- steam
- ubuntu-restricted-extras
- nautilus-admin
- unity-tweak-tool
- vlc