Add a rust role.
This commit is contained in:
parent
b1681eebc5
commit
49a8b1b360
@ -1,5 +1,5 @@
|
||||
dependencies:
|
||||
- users
|
||||
- fonts
|
||||
# - rust
|
||||
- rust
|
||||
# - plainmacs
|
||||
|
14
ansible/roles/rust/tasks/common.yaml
Normal file
14
ansible/roles/rust/tasks/common.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
|
||||
- include_tasks:
|
||||
file: tasks/peruser.yaml
|
||||
apply:
|
||||
become: yes
|
||||
become_user: "{{ initialize_user }}"
|
||||
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
|
||||
loop_control:
|
||||
loop_var: initialize_user
|
6
ansible/roles/rust/tasks/freebsd.yaml
Normal file
6
ansible/roles/rust/tasks/freebsd.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- rust-nightly
|
||||
- rust-analyzer
|
||||
state: present
|
7
ansible/roles/rust/tasks/linux.yaml
Normal file
7
ansible/roles/rust/tasks/linux.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- rustup
|
||||
- lldb # for lldb-vscode
|
||||
- musl # for building static binaries
|
||||
state: present
|
2
ansible/roles/rust/tasks/main.yaml
Normal file
2
ansible/roles/rust/tasks/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
- import_tasks: tasks/common.yaml
|
||||
# when: foo is defined
|
29
ansible/roles/rust/tasks/peruser.yaml
Normal file
29
ansible/roles/rust/tasks/peruser.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
- include_role:
|
||||
name: per_user
|
||||
|
||||
# - name: Create directories
|
||||
# file:
|
||||
# name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
# state: directory
|
||||
# mode: 0700
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - ".config/foo"
|
||||
|
||||
# - name: Copy files
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
|
||||
# mode: 0600
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - src: foo.conf
|
||||
# dest: .config/foo/foo.conf
|
||||
|
||||
- import_tasks: tasks/peruser_freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/peruser_linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
0
ansible/roles/rust/tasks/peruser_freebsd.yaml
Normal file
0
ansible/roles/rust/tasks/peruser_freebsd.yaml
Normal file
44
ansible/roles/rust/tasks/peruser_linux.yaml
Normal file
44
ansible/roles/rust/tasks/peruser_linux.yaml
Normal file
@ -0,0 +1,44 @@
|
||||
- name: Set nightly as the default toolchain
|
||||
command: "rustup default nightly-{{ rust_date }}"
|
||||
args:
|
||||
creates: "{{ account_homedir.stdout }}/.rustup/toolchains/nightly-{{ rust_date }}-x86_64-unknown-linux-gnu"
|
||||
|
||||
- name: Install the musl target
|
||||
command: rustup target add x86_64-unknown-linux-musl
|
||||
args:
|
||||
creates: "{{ account_homedir.stdout }}/.rustup/toolchains/nightly-{{ rust_date }}-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl"
|
||||
|
||||
# Needed by rust-analyzer (rust-analyzer will attempt to install via rustup on its own, but this will install it manually).
|
||||
- name: Install the nightly rust-src
|
||||
command: rustup component add rust-src
|
||||
args:
|
||||
creates: "{{ account_homedir.stdout }}/.rustup/toolchains/nightly-{{ rust_date }}-x86_64-unknown-linux-gnu/lib/rustlib/manifest-rust-src"
|
||||
|
||||
- name: Install the nightly rust-analyzer
|
||||
command: rustup component add rust-analyzer
|
||||
args:
|
||||
creates: "{{ account_homedir.stdout }}/.rustup/toolchains/nightly-{{ rust_date }}-x86_64-unknown-linux-gnu/bin/rust-analyzer"
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
loop:
|
||||
- .cargo
|
||||
|
||||
- name: Copy files
|
||||
no_log: true
|
||||
copy:
|
||||
src: "files/{{ item.src }}"
|
||||
dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
|
||||
mode: 0600
|
||||
owner: "{{ account_name.stdout }}"
|
||||
group: "{{ group_name.stdout }}"
|
||||
loop:
|
||||
- src: cargo_credentials.toml
|
||||
dest: .cargo/credentials
|
||||
- src: cargo_config.toml
|
||||
dest: .cargo/config
|
Loading…
Reference in New Issue
Block a user